+ 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
2 Respuestas
+ 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