JS Built-ins
← Math176 / 215
Mathroundbeginner

Math.round() β€” 4.5 rounds up

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

πŸ’‘ Hints (1)
  • β€’ When the fractional part is exactly 0.5, Math.round rounds toward +Infinity