while

while is a loop that executes when the condition is true.

It is similar to a for loop but has different syntax.

Syntax

while (condition) {
  code
}

Example

External

Mozilla Developer Network