The while loop part 2
The While Loop
Consider the following example.
The loop will continue to run as long as i is less than, or equal to, 10. Each time the loop runs, it will increase by 1.
This will output the values from 0 to 10.
Be careful writing conditions. If a condition is always true, the loop will run forever.
Fill in the blanks to print x's values from 1 to 5.
var x = 1;
(x <=
) {
document.write(x + "<br />");
x =
+ 1;
}
document.write(x + "<br />");
x =
}
Comments
Post a Comment