The do…while loop in Javascript

JavascriptFront End TechnologyWeb Development

The do...while loop is similar to the while loop except that the condition check happens at the end of the loop. This means that the loop will always be executed at least once, even if the condition is false.

For example,

Example

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

This will give the output −

Output

Hello
Hello
Hello
Hello
Hello
raja
Updated on 15-Jun-2020 08:50:59

Advertisements