The do...while Loop:
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.
Syntax:
do{
Statement(s) to be executed;
} while (expression);
|
Note the semicolon used at the end of the
do...while loop.
Example:
<script type="text/JavaScript">
<!--
var count = 0;
document.write("Starting Loop" + "<br />");
do{
document.write("Current Count : " + count + "<br />");
count++;
}while (count < 0);
document.write("Loop stopped!");
//-->
</script>
|
No comments:
Post a Comment