course content

Course Content

Introduction to JavaScript

do whiledo while

Consider the do-while loop. This loop is similar to the while loop but has a difference.

Executes code block after the conditional checking.Executes code block before the conditional checking.


The do-while loop starts with the do keyword, includes the code block ({}), and ends with the while keyword followed by the condition (()) without the code block:

At the start, the variable a was equal to 0, but the condition a >= 1 was checked after the a = a + 1 operation.

The do code block is always executed at least once:


The end of the command (;) after the do code block will result in a SyntaxError.

Section 5.

Chapter 2