JS Built-ins
← Math42 / 215
Mathabsbeginner

Positive Numbers Stay Positive

πŸ“– Usage Example
// Get the absolute value of a number
Math.abs(-7)   // β†’ 7
Math.abs(3.5)  // β†’ 3.5

Use Math.abs() when you need the magnitude of a number regardless of its sign.

Math.abs(x)

When passed a positive number, Math.abs() returns it unchanged.

Challenge: Verify that Math.abs() leaves positive numbers unchanged.

πŸ’‘ Hints (2)
  • β€’ Positive numbers are unaffected by Math.abs()
  • β€’ Zero is neither positive nor negative