Parse Integer in JavaScript

Level 128 keystrokes

parseInt() converts the string "42" into the number 42 and prints it.

JavaScript code

// parseInt() reads digits from the start of a string and returns an integer
// "42" becomes 42; it stops at the first non-digit, so "42px" also gives 42
1console.log(parseInt("42"));

Output

42
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

More JavaScript examples at level 1

← JavaScript typing practice