"while"

Let i = 0;
while (i < 3) { // shows 0, then 1, then 2
  alert( i );
  i++;
}

While the condition is true, the code from the loop body is executed.

A single execution of the loop body is called an iteration. The loop in the example makes three iterations.

Syntax

While (condition) {
  // code
  // so-called "loop body"
}

Related concepts

"while"

"while" — Structure map

Clickable & Draggable!

"while" — Related pages: