Problems with Nodejs on Linux

Asked

Viewed 48 times

-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

  • 2

    The "PI" of Math.PI is all capital

  • 2

    This is not syntax. It’s just the variable name. :)

  • Language is sensitive case, it differentiates between upper and lower case, so keep in mind that Math.PI is different from Math.pI which is different from Math.Pi which in turn is a different field de Math.pi and javascript documentation is very clear when declaring that the field name is Math.PI.

1 answer

1

The problem is occurring due to syntax error (incorrectly typed code)

The PI of Math.PI is written in capital letters

Stay that way

const area = Math.PI * Math.pow(raio, 2)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.