February 2018
Intermediate to advanced
298 pages
8h 22m
English
The Math.sign() function returns the sign of a number, indicating whether the number is negative, positive, or zero. Here is an example to demonstrate this:
console.log(Math.sign(11));console.log(Math.sign(-11));console.log(Math.sign(0));
The output is as follows:
1-10
From the preceding code, we can see that the Math.sign() function returns 1 if the number is positive, -1 if the number is negative, and 0 if the number is zero.
Read now
Unlock full access