0
0
Javascriptprogramming~20 mins

Continue statement in Javascript - Practice Problems & Coding Challenges

Choose your learning style9 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.