Search code examples
javascriptfunctionhypotenuse

Hypotenuse using function & Math.sqrt() javascript


Hello I am doing this function calculating the hypotenuse. here the code I created so far. I have to use the Math.sqrt() method which is a part of the requirement. Once the code is running nothing occurs. Thanks for your help guys!

 function getHeight() {
 var n = 5;
 return = n;
 }
 function getWidth() {
 var n = 12;
 return n;
 }
 function getHypotenuse(height,width) {
 var hypotenuse = Math.sqrt(height*height + width*width);
 return hypotenuse;
 }
 function displayHypotenuse() {
 alert("the hypotenuse is: " + getHypotenuse(getHeight(),getWidth()));
 }
 function init() {
 displayHypotenuse();
 }
 window.onload = init;

Solution

  • Instead of

    function getHeight() {
     var n = 5;
     return = n;
     }
    

    use

    function getHeight() {
     var n = 5;
     return n;
     }
    

    The issue is with return = n