JavaScript do...while Loop
The JavaScript do while loop iterates the elements for the infinite number of times like while loop. But, code is executed at least once whether condition is true or false. The syntax of do while loop is given below.
Syntax:
do {
// Statements to be executed
} while (condition);
// Statements to be executed
} while (condition);
Try the following example to learn how a do...while loop works in JavaScript.
Example:
var count = 0;
do {
document.write ("Current Count : " + count );
count++;
} while(count < 10);
do {
document.write ("Current Count : " + count );
count++;
} while(count < 10);
Run Example