Iteration Statements
An iteration is the repetition of a sequence of statements either
A specified number of times
Until a condition is met
Four iteration statements are available:
The do ... while statement
The while statement
The for statement
The for ... in statement
Each of these statements performs a slightly different task, but each is a useful statement to learn how to use.
The do ... while Statement
The do ... while statement runs a statement or a block of statements and then repeats the whole process until the condition expression is false. An example will clarify this:
<script language="JavaScript"> <!-- Cloaking device on! var x = 1 do { ++x; alert(x); } while (x < 10); // Cloaking device off --> </script>
The previous code has a variable, ...
Get JavaScript™ 1.5 by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.