JavaScript · Junior · Question 67 of 75
What does Math.round(-2.5) return?
- ✓Correct answer:
-2 - 2
-3 - 3
-2.5
Explanation
Math.round rounds .5 towards +∞, so Math.round(2.5) is 3 and Math.round(-2.5) is -2. Use Math.trunc, Math.floor or Intl.NumberFormat when you need other rules.