While Loop Counter in JavaScript

Level 265 keystrokes

A while loop repeats code as long as the condition is true.

JavaScript code

// let declares a variable that can be changed
// Initialize count to 0
1let count = 0;
// while loop runs while count is less than 3
2while (count < 3) {
// Output current value of count
3 console.log(count);
// Increment count by 1
4 count++;
5}

Output

0
1
2
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.

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

More JavaScript examples at level 2

← JavaScript typing practice