LESSON 26 OF 50

Skip an iteration with continue

Do not print 3, but continue with later values.

Official sourceECMAScript — continue statementReviewed: 2026-08-26
STEP 1 · LEARN

How it works

continue ends the current iteration and moves to the next loop step. Unlike break, it does not stop the whole loop.

Correct example
for (let number = 1; number <= 5; number += 1) {
  if (number === 3) {
    continue;
  }
  console.log(number);
}

At value 3, console.log is skipped; the loop continues with 4 and 5.

Common mistake
if (number === 3) { break; }

break would stop the entire loop, so 4 and 5 would not appear.

STEP 2 · APPLY

Your exercise

Print 1, 2, 4 and 5; use continue when number is 3.

STEP 3 · RUN

Write and run the code

script.jsJAVASCRIPT
Isolated consoleisolated
Preparing the runtime…
Run the code to see the result.
The draft stays only in this browser.Isolated QuickJS · no DOM, session or network
STEP 4 · CHECK

What needs to pass

0%not checked
  • The loop uses continue inside an if that checks number === 3.
  • The for loop updates number and prints the remaining values.
  • The output is 1, 2, 4, 5.
Explain the solution logic

continue skips only the printing of 3, while the loop update keeps it moving forward.