Cube Root in JavaScript

Level 127 keystrokes

Math.cbrt() returns the cube root of 27 and prints 3.

JavaScript code

// Math.cbrt() returns the number that, cubed, gives the argument
// 3 * 3 * 3 = 27, so 3 is printed; negatives work too: Math.cbrt(-8) is -2
1console.log(Math.cbrt(27));

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