Square Root in JavaScript

Level 127 keystrokes

Uses Math.sqrt() to print the square root of 16, which is 4.

JavaScript code

// Math.sqrt() returns the number that, multiplied by itself, gives the argument
// 4 * 4 = 16, so 4 is printed; Math.sqrt(-1) would return NaN
1console.log(Math.sqrt(16));

Output

4
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