Recall & Review
beginner
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.
Click to reveal answer
beginner
In which types of loops can you use the
continue statement in JavaScript?You can use
continue in for, while, and do...while loops.Click to reveal answer
intermediate
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.
Click to reveal answer
beginner
How is
continue different from break in loops?continue skips to the next iteration, while break exits the entire loop immediately.Click to reveal answer
beginner
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:<br>1<br>2<br>4<br>5<br>The number 3 is skipped because
continue skips that iteration.Click to reveal answer
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?<br>
for(let i=0; i<4; i++) {<br> if(i === 2) continue;<br> console.log(i);<br>}✗ 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.