Recently I was working on one of my projects and I encountered one scenario in which I had to check that whether the number is positive or negative according to the number’s nature I had to run the logic and then I came to know about Math.sign(). I should share this thing with you 😊..

There is a built in fuctinon in javascript Math.sign(), The Math.sign() function returns either a positive or negative +/- 1, indicating the sign of a number passed into the argument. If the number passed into Math.sign() is 0, it will return a +/- 0. Note that if the number is positive, an explicit (+) will not be returned.


// expected output: 1

// expected output: -1

// expected output: 0

// expected output: -1

If you find it helpfull please share with your network βœ….

Happy Coding πŸ™Œ !