JavaScript Math methods/functions 😭 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

JavaScript Math methods/functions 😭

var num = -50 console.log(abs(num)); /* console.log(ceil(num)); console.log(cos(num)); console.log(pow(5, 2)); console.log(sqt(num)); console.log(tan(num)); console.log(sin(num)); */ /*output is "Uncaught ReferenceError: abs is not defined " can someone explain why?? */

27th Aug 2020, 2:45 PM
David Holmes Ng'andu
David Holmes Ng'andu - avatar
1 Answer
+ 5
abs() function is defined in Math object. You have to say Math.abs(); For example: console.log(Math.abs(num)); reference: https://www.sololearn.com/learn/JavaScript/1243/
27th Aug 2020, 2:47 PM
Raj Chhatrala
Raj Chhatrala - avatar