do

Loops through the statements enclosed within the { code block } until the following while test expression is false:

 

do {
statements ;
} while (test expression) ;

 

*note the ending semi-colon ; after the while test expression!

 

The do loop will always be executed at least once, even if the condition is false, because the code block is executed before the condition is tested:

Save & refresh browser:

val = 5
val = 6
val = 7
val = 8
val = 9

Leave a Reply