Simple If Statement in JavaScript

Level 246 keystrokes

This checks if x is greater than 5 and outputs 'big' if true.

JavaScript code

// Declare a variable x with value 10
1let x = 10;
// if statement checks a condition in parentheses
// If x > 5 is true, the code block executes
2if (x > 5) {
// This runs because 10 > 5 is true
3 console.log("big");
4}

Output

big
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.

  • ;× 2
  • "× 2
  • (× 2
  • )× 2
  • .× 1
  • {× 1
  • }× 1
  • =× 1
  • >× 1

More JavaScript examples at level 2

← JavaScript typing practice