Utilizor
Contact Us

Do...While Loop

The do...while loop syntax.

Do...While Loop

The do...while loop is a variant of the while loop.

This loop will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.

do { // code block to be executed } while (condition);

Example

let i = 0;
do {
  console.log(i);
  i++;
}
while (i < 5);