Bird
Raised Fist0
Javascriptprogramming~20 mins

Continue statement in Javascript - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
๐ŸŽ–๏ธ
Continue Statement Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
โ“ Predict Output
intermediate
2:00remaining
Output of loop with continue
What is the output of the following code?
Javascript
let result = '';
for (let i = 0; i < 5; i++) {
  if (i === 2) continue;
  result += i;
}
console.log(result);
A"01234"
B"024"
C"1234"
D"0134"
Attempts:
2 left
๐Ÿ’ก Hint
The continue statement skips the current loop iteration when i equals 2.
โ“ Predict Output
intermediate
2:00remaining
Continue in while loop output
What will be logged by this code?
Javascript
let count = 0;
let output = '';
while (count < 5) {
  count++;
  if (count === 3) continue;
  output += count;
}
console.log(output);
A"12345"
B"1245"
C"1234"
D"124"
Attempts:
2 left
๐Ÿ’ก Hint
The continue skips adding when count is 3.
โ“ Predict Output
advanced
2:30remaining
Continue with nested loops output
What is the output of this nested loop code?
Javascript
let result = '';
for (let i = 1; i <= 3; i++) {
  for (let j = 1; j <= 3; j++) {
    if (j === 2) continue;
    result += `${i}${j} `;
  }
}
console.log(result.trim());
A"11 13 21 23 31 33"
B"12 13 22 23 32 33"
C"11 12 13 21 22 23 31 32 33"
D"11 13 22 23 31 33"
Attempts:
2 left
๐Ÿ’ก Hint
The continue skips inner loop when j equals 2.
โ“ Predict Output
advanced
2:00remaining
Continue in forEach callback
What will this code output?
Javascript
const arr = [1, 2, 3, 4];
let sum = 0;
arr.forEach(num => {
  if (num === 3) continue;
  sum += num;
});
console.log(sum);
A10
B7
CSyntaxError
DTypeError
Attempts:
2 left
๐Ÿ’ก Hint
continue cannot be used inside forEach callback.
๐Ÿง  Conceptual
expert
2:30remaining
Effect of continue on loop variable
Consider this code snippet. What is the final value of i after the loop ends?
Javascript
let i = 0;
while (i < 5) {
  i++;
  if (i === 3) continue;
  i++;
}
console.log(i);
A5
B6
C8
D7
Attempts:
2 left
๐Ÿ’ก Hint
Notice how continue skips the second increment when i is 3.

Practice

(1/5)
1. What does the continue statement do inside a loop in JavaScript?
easy
A. It skips the rest of the current loop iteration and moves to the next iteration.
B. It stops the entire loop immediately.
C. It restarts the whole program from the beginning.
D. It pauses the loop until a condition is met.

Solution

  1. Step 1: Understand the role of continue in loops

    The continue statement skips the remaining code inside the current loop iteration.
  2. Step 2: Identify what happens after continue

    After skipping, the loop moves directly to the next iteration without stopping the whole loop.
  3. Final Answer:

    It skips the rest of the current loop iteration and moves to the next iteration. -> Option A
  4. Quick Check:

    continue skips current step [OK]
Hint: Remember: continue skips current step, break stops loop [OK]
Common Mistakes:
  • Confusing continue with break
  • Thinking continue stops the loop
  • Believing continue restarts the program
2. Which of the following is the correct syntax to use continue inside a for loop in JavaScript?
easy
A. continue[];
B. continue;
C. continue loop;
D. continue()

Solution

  1. Step 1: Recall the syntax of continue

    The continue statement is used alone followed by a semicolon.
  2. Step 2: Check each option for syntax correctness

    continue; uses continue; which is correct. Options A, B, and C use invalid syntax.
  3. Final Answer:

    continue; -> Option B
  4. Quick Check:

    Correct syntax is continue; [OK]
Hint: Use continue as a statement, no parentheses or brackets [OK]
Common Mistakes:
  • Adding parentheses after continue
  • Using continue with labels incorrectly
  • Adding brackets or other symbols
3. What will be the output of the following code?
for (let i = 1; i <= 5; i++) {
  if (i === 3) continue;
  console.log(i);
}
medium
A. 1 2 3 4 5
B. 3 4 5
C. 1 2 4 5
D. 1 2

Solution

  1. Step 1: Analyze the loop and condition

    The loop runs from 1 to 5. When i is 3, continue skips the console.log.
  2. Step 2: Determine which numbers are printed

    Numbers 1, 2, 4, and 5 are printed. Number 3 is skipped.
  3. Final Answer:

    1 2 4 5 -> Option C
  4. Quick Check:

    continue skips 3, prints others [OK]
Hint: Skip printing when continue runs, others print [OK]
Common Mistakes:
  • Including the skipped number in output
  • Confusing continue with break
  • Ignoring the condition inside the loop
4. Find the error in this code snippet:
for (let i = 0; i < 5; i++) {
  if (i = 2) continue;
  console.log(i);
}
medium
A. The assignment operator (=) is used instead of comparison (===) in the if condition.
B. continue cannot be used inside for loops.
C. console.log should be before the if statement.
D. The loop condition should be i <= 5.

Solution

  1. Step 1: Identify the if condition mistake

    The condition uses i = 2 which assigns 2 to i instead of comparing.
  2. Step 2: Understand the effect of assignment in if

    Assignment returns 2 (truthy), so continue runs every time, causing an infinite loop or skipping all logs.
  3. Final Answer:

    The assignment operator (=) is used instead of comparison (===) in the if condition. -> Option A
  4. Quick Check:

    Use === for comparison, not = [OK]
Hint: Use === for comparison inside if, not = [OK]
Common Mistakes:
  • Using = instead of === in conditions
  • Thinking continue is invalid in for loops
  • Misplacing console.log inside loop
5. You want to print all numbers from 1 to 10 except multiples of 3 using a for loop and continue. Which code correctly achieves this?
hard
A. for(let i=1; i<=10; i++) { if(i % 3 === 0) return; console.log(i); }
B. for(let i=1; i<=10; i++) { if(i % 3 !== 0) continue; console.log(i); }
C. for(let i=1; i<=10; i++) { if(i % 3 === 0) break; console.log(i); }
D. for(let i=1; i<=10; i++) { if(i % 3 === 0) continue; console.log(i); }

Solution

  1. Step 1: Understand the goal

    We want to skip printing numbers divisible by 3, so use continue when i % 3 === 0.
  2. Step 2: Check each option

    for(let i=1; i<=10; i++) { if(i % 3 === 0) continue; console.log(i); } correctly skips multiples of 3 and prints others. for(let i=1; i<=10; i++) { if(i % 3 !== 0) continue; console.log(i); } skips non-multiples, wrong. for(let i=1; i<=10; i++) { if(i % 3 === 0) break; console.log(i); } uses break, stops loop early. for(let i=1; i<=10; i++) { if(i % 3 === 0) return; console.log(i); } uses return, invalid in this context.
  3. Final Answer:

    for(let i=1; i<=10; i++) { if(i % 3 === 0) continue; console.log(i); } -> Option D
  4. Quick Check:

    continue skips multiples of 3, prints rest [OK]
Hint: Use continue to skip unwanted cases inside loop [OK]
Common Mistakes:
  • Using break instead of continue
  • Reversing the condition logic
  • Using return inside loops incorrectly
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard