Continue Statement in JavaScript

Level 275 keystrokes

Loops from 1 to 5 and uses continue to skip the even numbers, printing only the odd ones.

JavaScript code

1for (let i = 1; i <= 5; i++) {
// continue jumps straight to the next iteration when i is even
2 if (i % 2 === 0) continue;
// Only odd numbers reach this line: 1, 3, 5
3 console.log(i);
4}

Output

1
3
5
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this JavaScript code and how often they appear.

  • =× 5
  • ;× 4
  • (× 3
  • )× 3
  • +× 2
  • .× 1
  • {× 1
  • }× 1
  • %× 1
  • <× 1

More JavaScript examples at level 2

← JavaScript typing practice