bbb Home |
Looping | Contents |
for i = 0 to 10
print i
next i
for (i = 0; i <= 10; i++) {
document.write(i);
};
Translation please...
for (start; continue while this is true; do this at end of loop) {
Code to do each loop ... can be multiple statements
};
var i = 0
while(i <= 10) {
document.write(i);
};
Font: 8pt 12pt 20pt 24pt Width: Min. 50% 75% 100% |
1. Write a for loop to display even numbers between 2 and 8 in an alert, one at a time.
2. Write a while loop display even numbers between 2 and 8 in an alert, one at a time.
3. Write a for loop that adds up all numbers between 1 and 10.
4. Write a while loop that keeps prompting the user for a word until the word is "bob" or "BOB". After the user enters "bob" or "BOB", display "thanks" in an alert.
5. Nest a loop in a loop to write out the multiplication table for numbers between 1 and 9.