0

Advanced math

I'm making a big calculator. I've already added PI and Square Root. But I want to add (x)^(2). JavaScript doesn't understand that and just sums them up. Do I need to make a function for it? function X2() { return x*x; } Or some kind of operator overloading? Please post an example.

20th Aug 2016, 9:49 PM
Oscar
Oscar - avatar
1 Answer
+ 4
Hi Use Math.pow(x, 2) it will return what you need.
21st Aug 2016, 2:22 PM
Grzegorz BielaƄski
Grzegorz BielaƄski - avatar