0
0
Javascriptprogramming~5 mins

Continue statement in Javascript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ASkips the rest of the current iteration and moves to the next iteration
BExits the entire loop immediately
CRestarts the whole program
DPauses the loop for a moment
In which loop types can you use continue in JavaScript?
A<code>for</code>, <code>while</code>, and <code>do...while</code> loops
BOnly <code>while</code> loops
COnly <code>for</code> loops
DOnly <code>do...while</code> loops
What happens if continue is used inside a nested loop?
AIt skips the current iteration of the outer loop
BIt skips the current iteration of the innermost loop where it is used
CIt exits all loops immediately
DIt restarts the outer loop
Which statement immediately exits the entire loop?
Acontinue
Bexit
Creturn
Dbreak
What will this code print?<br>
for(let i=0; i<4; i++) {<br>  if(i === 2) continue;<br>  console.log(i);<br>}
A0 1 2 3
B1 2 3
C0 1 3
D2 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.