Recall & Review
beginner Click to reveal answer
What does the
continue statement do in a loop?It skips the rest of the current loop iteration and moves to the next iteration immediately.
beginner Click to reveal answer
In which types of loops can you use the
continue statement in JavaScript?You can use
continue in for, while, and do...while loops.intermediate Click to reveal answer
What happens if
continue is used inside a nested loop?It only skips the current iteration of the innermost loop where it is used, not outer loops.
beginner Click to reveal answer
How is
continue different from break in loops?continue skips to the next iteration, while break exits the entire loop immediately.beginner Click to reveal answer
Example: What will this code output?<br><pre>for(let i = 1; i <= 5; i++) {<br> if(i === 3) continue;<br> console.log(i);<br>}</pre>It will print:
1
2
4
5
The number 3 is skipped because
1
2
4
5
The number 3 is skipped because
continue skips that iteration.What does the
continue statement do inside a loop?✗ Incorrect
continue skips the rest of the current loop iteration and continues with the next one.In which loop types can you use
continue in JavaScript?✗ Incorrect
continue works in all three loop types: for, while, and do...while.What happens if
continue is used inside a nested loop?✗ Incorrect
continue affects only the innermost loop it is inside, skipping its current iteration.Which statement immediately exits the entire loop?
✗ Incorrect
break exits the entire loop immediately, unlike continue which skips only the current iteration.What will this code print?
for(let i=0; i<4; i++) {
if(i === 2) continue;
console.log(i);
}✗ Incorrect
The number 2 is skipped because
continue skips that iteration, so output is 0, 1, and 3.Explain how the
continue statement changes the flow inside a loop.Think about what happens when you want to skip some steps but keep looping.
You got /3 concepts.
Describe the difference between
continue and break in loops.One skips steps, the other stops completely.
You got /3 concepts.
