|
| WHILE LOOPS IN JAVASCRIPT
A while loop in javascript tests a certain condition and as long as that condition evaluates to true, a block of code between the curly braces will continuously execute. Execution will stop only when the condition evaluates to
false.
The general format is:
while(certain condition)
{
execute this code;
}
Example:
i=1;
while(i <= 10)
{
document.write("Bart Simpsonwas here.<br>");
i++;
}
The above code will output Bart Simpson was here. ten times and only stop when i is equal to 11.
|
|