Hypotenuse Length in JavaScript

Level 130 keystrokes

Math.hypot(3, 4) returns the length of the hypotenuse of a right triangle with sides 3 and 4, and prints 5.

JavaScript code

// Math.hypot() returns the square root of the sum of the squares of its arguments
// sqrt(3 ** 2 + 4 ** 2) = sqrt(25) = 5, the Pythagorean theorem
1console.log(Math.hypot(3, 4));

Output

5
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