math sign

Solutions on MaxInterview for math sign by the best coders in the world

showing results for - "math sign"
Sofia
06 Jul 2018
1//The Math.sign() function returns either a positive or negative +/- 1,
2//indicating the sign of a number passed into the argument. If the number passed into 
3//Math.sign() is 0, it will return a +/- 0. Note that if the number is positive,
4//an explicit (+) will not be returned.
5
6Math.sign(3);     //  1
7Math.sign(-3);    // -1
8Math.sign('-3');  // -1
9Math.sign(0);     //  0
10Math.sign(-0);    // -0
11Math.sign(NaN);   // NaN
12Math.sign('foo'); // NaN
13Math.sign();      // NaN
14