Logarithm Base 10 in JavaScript

Level 130 keystrokes

Math.log10() returns the base-10 logarithm of 1000 and prints 3.

JavaScript code

// Math.log10(x) answers "10 to what power equals x?"
// 10 ** 3 = 1000, so 3 is printed; it roughly counts digits minus one
1console.log(Math.log10(1000));

Output

3
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

More JavaScript examples at level 1

← JavaScript typing practice