Thuta Learning
BasicProgrammingbeginner

JS While Loop

Relax. We'll talk through this in plain words — no textbook voice.

while loop runs a block of code repeatedly for as long as a given condition remains true.

javascript
let i = 0;
let text = "";

while (i < 5) {
  text += "The number is " + i + "\n";
  i++;
}
console.log(text);
You should see
The number is 0 The number is 1 The number is 2 The number is 3 The number is 4
JS While Loop | Thuta Learning