JS Built-ins
← Math41 / 215
Mathabsbeginner

Negative to Positive with Math.abs()

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

Returns the absolute value of a number, converting negative numbers to positive.

Challenge: Use Math.abs() to convert a negative number to its positive equivalent.

πŸ’‘ Hints (2)
  • β€’ Math.abs() strips the sign from a number
  • β€’ Works with integers and floats alike