0

Can you please find the mistake.it's my first code in java script

alert("please upvote if you like") var n = prompt("Enter a number", ""); var answer = Maths.sqrt(n); document.write("The square root of " + n + " is " + answer);

19th Mar 2020, 3:58 PM
Rishik Reddy
Rishik Reddy - avatar
2 ответов
+ 7
Object name is Math, not Maths. There is a nice documentation if you ever need to see syntax https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math
19th Mar 2020, 3:59 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
0
Rishik Reddy , hello Also to use your input as a number you will have to convert it as a number, the prompt input return a type string. Doesn't using answer variable giving you an error or something like NaN?
20th Mar 2020, 1:21 AM
EmmanueLZ.
EmmanueLZ. - avatar