JavaScript » Statements » while

Syntax:
while

The while statement creates a loop consisting of a block of statements that is executed if the expression evaluated is true.

Examples

Code:
var i = 0;
while(i<11)
{
   document.write(i + "<BR>");
   i++;
}
Explanation:

This example simply counts 1 thru 10 by incrementing a counter by 1 each time for as long as the counter is less than 11.