HTML and CSS Reference
In-Depth Information
Figure 6.4 Output from Example 6.5.
6.3.2 The do/while Loop
The do/while statement executes a block of statements repeatedly until a condition
becomes false. Owing to its structure, this loop necessarily executes the statements in
the body of the loop at least once before testing its expression, which is found at the bot-
tom of the block. The do/while loop is supported in Mozilla/Firefox and Internet
Explorer 4.0, JavaScript 1.2, and ECMAScript v3.
FORMAT
do
{ statements;}
while (condition);
EXAMPLE 6.6
<html>
<head>
<title>Looping Constructs</title>
</head>
<body>
<h2>Do While Loop</h2>
<font size="+2">
<script type="text/javascript">
1
var i=0;
2
do{
3
document.writeln(i);
4
i++;
5
} while ( i < 10 )
</script>
</font>
</body>
</html>
 
 
Search WWH ::




Custom Search