1
2
3
4
5
6
7
8
9
10
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.
0,1,2,3,4,5,6,7,8,9
0
0
0
0
The counter name is i. Start it at 0. | for (_________; i <= 4; i++) { | let i = 0 | leti=0 |
The last element of the array has an index of 9. Fill in the blank, to limit the number of loops. | for (let i = 0; _____; i++) { | i < 10 | i<10 |
The counter is to increment by 1 after each loop. Fill in the blank. | for (let i = 0; i < 10; ____) { | i++ | i\+\+ |
What is the keyword that stops a loop? | break | break | |
Code the first line of a for loop, starting i at 0 and incrementing by 1 on each iteration. Run it 4 times. | for (let i = 0; i < 4; i++) { | for\(leti=0;i<4;i\+\+\){ | |
Code the first line of a for loop using a counter name that's not i. Start it at 0. Run it 100 times. Increment by 1 with each iteration. Make up the counter name. | for (let trys = 0; trys < 100; trys++) { | for\(let([a-z_$][a-zA-Z0-9_$]*)=0;\1<100;\1\+\+\){ | |
Code the first line of a for loop with the usual counter and the usual starting value. Run it 3 times. Increment it by 1 with each iteration. | for (let i = 0; i < 3; i++) { | for\(leti=0;i<3;i\+\+\){ | |
|
for (let i = 0; i < 5; i++) { if (answers[i] === "yes") { positive = 1; break; } } |
for\(let([a-z_$][a-zA-Z0-9_$]*)=0;\1<5;\1\+\+\){[\r\n]if\(answers\[\1\]===•yes•\){[\r\n][a-z_$][a-zA-Z0-9_$]*=(0|-?[1-9][\d]*);[\r\n]break;[\r\n]}[\r\n]} | |
|
|||
|