JavaScript · Junior · Question 67 of 75

What does Math.round(-2.5) return?

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.

Further reading

Problem with a question

JavaScript · Junior · question 67

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz