JS Built-ins
← Math117 / 215
Mathfloorbeginner

Math.floor(-4.1) Equals -5

πŸ“– Usage Example
// Round down to the nearest integer
Math.floor(4.9)   // β†’ 4
Math.floor(-4.1)  // β†’ -5

Use Math.floor() when you need to round a number down to the nearest whole integer.

Math.floor(x)

For negative numbers, Math.floor() rounds away from zero. Math.floor(-4.1) returns -5.

Challenge: Use Math.floor() on a negative number.

πŸ’‘ Hints (2)
  • β€’ floor always rounds toward -∞, which for negatives means away from zero
  • β€’ Compare with Math.ceil(-4.1) = -4