Nearby lessons

18 of 40

🔄 JavaScript while Loop

📌 What is JavaScript while Loop?

The while loop executes code while a condition is true.

Ideal when the number of iterations is unknown.

📋 while Loop Basics

AttributeDescription
Syntaxwhile (condition)
ConditionEvaluated before each iteration
UsageWhen iterations are unknown

🔹Print 1 to 10 Using while loop

Example03
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🔹Print 10 to 1 Using while loop

Example04
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🔹Print Even Number Using while loop

Example05
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🔹Print Odd Number Using while loop

Example06
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🧠 Test Your Knowledge

2 Questions
Progress: 0 / 2