-2
I have a problem, I’ve tried several ways and nothing.
I’m taking a JS course, and in one of the classes the teacher used the Math library... only my result is always Nan. So researching I found that this is kind of a Linux dependency problem.
I uninstalled Nodejs and Visual Studio Code Editor from my PC, and reinstalled and nothing...
The script was:
const radius = 5.6
const area = Math.Pi * Math.Pow(radius, 2)
console.log(area)
Upshot:
Nan
The "PI" of
Math.PI
is all capital– Sam
This is not syntax. It’s just the variable name. :)
– Luiz Felipe
Language is sensitive case, it differentiates between upper and lower case, so keep in mind that
Math.PI
is different fromMath.pI
which is different fromMath.Pi
which in turn is a different fieldde Math.pi
and javascript documentation is very clear when declaring that the field name is Math.PI.– Augusto Vasques