JS Built-ins
← Math43 / 215
Mathabsbeginner

Absolute Value of Zero

πŸ“– 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)

Both 0 and -0 have an absolute value of 0.

Challenge: Explore the absolute value of zero and negative zero.

πŸ’‘ Hints (2)
  • β€’ In JavaScript, -0 exists but Math.abs(-0) === 0
  • β€’ Both 0 and -0 have absolute value 0