mh108
1/15/2019 - 8:53 PM

Hypotenuse of a right triangle

Example of a program file

// jshint esversion: 7

function hypotenuse(a, b){
   return Math.sqrt(a**2 + b**2);
}

let hypot, h2, sideA, sideB;

//Input: 
sideA = Number(prompt("enter A"));
sideB = Number(prompt("enter B"));

//Processing:
hypot = hypotenuse(sideA, sideB);

//Output
console.log(`sideA = ${sideA} sideB = ${sideB} hypotenuse = ${hypot}`);