Increment Operator in JavaScript

Level 275 keystrokes

Demonstrates ++ to increment by 1 and += to increment by a specific value.

JavaScript code

// Declare a variable with the value 5
1let count = 5;
// ++ adds 1 to the variable (count becomes 6)
2count++;
// Output the current value (6)
3console.log(count);
// += adds a specific value (3) to the variable
4count += 3;
// Output the new value (9)
5console.log(count);

Output

6
9
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
  • +× 3
  • .× 2
  • (× 2
  • )× 2
  • =× 2

More JavaScript examples at level 2

← JavaScript typing practice