Complete the code to create a loop that runs 5 times.
for(let i = 0; i [1] 5; i++) { console.log(i); }
The loop should run while i is less than 5, so it runs 5 times from 0 to 4.
Complete the code to stop the loop when i equals 3.
for(let i = 0; i < 5; i++) { if(i [1] 3) { break; } console.log(i); }
The loop should stop when i is equal to 3, so we use == to check equality.
Fix the error in the loop to skip printing when i is 2.
for(let i = 0; i < 5; i++) { if(i [1] 2) { continue; } console.log(i); }
To skip printing when i is 2, use == to check equality and continue the loop.
Fill both blanks to create a loop that prints only even numbers from 0 to 8.
for(let i = 0; i [1] 10; i[2]) { if(i % 2 === 0) { console.log(i); } }
The loop runs while i is less than 10 and increments by 1 each time using ++.
Fill all three blanks to create a loop that prints numbers from 10 down to 1.
for(let i = [1]; i [2] 0; i[3]) { console.log(i); }
The loop starts at 10, runs while i is greater than 0, and decreases i by 1 each time using --.
