JS Built-ins
← Math126 / 215
Mathhypotbeginner

Math.hypot() β€” 3-4-5 Triangle

πŸ“– Usage Example
// Euclidean distance / hypotenuse
Math.hypot(3, 4)   // β†’ 5
Math.hypot(5, 12)  // β†’ 13

Use Math.hypot() to calculate the hypotenuse of a right triangle or Euclidean distance between points.

Math.hypot()

Returns the square root of the sum of squares of its arguments.

Challenge: Use Math.hypot(3, 4) to compute the hypotenuse of a 3-4-5 right triangle.

πŸ’‘ Hints (1)
  • β€’ The 3-4-5 Pythagorean triple: sqrt(9 + 16) = sqrt(25) = 5