JS Built-ins
← Math180 / 215
Mathroundbeginner

Math.round() β€” -4.6 rounds to -5

πŸ“– Usage Example
// Round to nearest integer (ties go up)
Math.round(4.5)   // β†’ 5
Math.round(4.4)   // β†’ 4

Use Math.round() to round a number to the nearest integer, with ties (.5) rounding up.

Math.round()

Returns the value of a number rounded to the nearest integer.

Challenge: Verify that Math.round(-4.6) returns -5.

πŸ’‘ Hints (1)
  • β€’ -4.6 is closer to -5 than to -4, so it rounds to -5