Const Declaration in JavaScript

Level 247 keystrokes

This declares a constant PI and outputs it in a message.

JavaScript code

// const declares a constant that cannot be reassigned
// By convention, constants are often UPPERCASE
1const PI = 3.14159;
// PI = 3.14 would cause an error
// The + operator concatenates the string with PI
2console.log("Pi is " + PI);

Output

Pi is 3.14159
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
  • (× 1
  • )× 1
  • +× 1
  • =× 1

More JavaScript examples at level 2

← JavaScript typing practice