JS Built-ins
← Math181 / 215
Mathsignbeginner

Math.sign() β€” Positive Number

πŸ“– 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: Verify that Math.sign(5) returns 1.

πŸ’‘ Hints (1)
  • β€’ Math.sign returns 1 for any positive number