JS Built-ins
← Math185 / 215
Mathsignintermediate

Math.sign() β€” NaN Input

πŸ“– Usage Example
// Returns -1, 0, or 1 based on sign
Math.sign(-5)   // β†’ -1
Math.sign(0)    // β†’ 0
Math.sign(3)    // β†’ 1

Use Math.sign() to determine whether a number is positive, negative, or zero.

Math.sign()

Returns the sign of a number, indicating whether it is positive, negative, or zero.

Challenge: Observe that Math.sign(NaN) returns NaN.

πŸ’‘ Hints (1)
  • β€’ NaN propagates through Math.sign β€” NaN has no defined sign