The Do...While Loop

The Do...While Loop
16
1/1





The 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, and then it will repeat the loop as long as the condition is true.
Syntax:do {
code block
}
while (condition);
Note the semicolon used at the end of the do...while loop.
Example:
This prints out numbers from 20 to 25.
The loop will always be executed at least once, even if the condition is false, because the code block is executed before the condition is tes
Apply the "do" and "while" keywords in their corresponding positions.
var count=1;
{
document.write("hello <br />");
count++;
}
(count<=10);
document.write("hello <br />");
count++;
}
Comments
Post a Comment