Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Working With Numbers Review Working with Numbers

I keep getting this question wrong, is Math.round?

On the quiz doing the fill in the blank.

5 Answers

Per Karlsson
Per Karlsson
12,683 Points

Hey Rachel,

Try using Math.floor instead and see if it works better for you :)

Duh. Just realized. Wow. Thank you.

Question

Complete the following code so that the results of this math operation are rounded down to the nearest integer. For example, .6 will be rounded to 0.

To round down numbers in JS you need to use Math.floor() method.

The question says "rounded down to the NEAREST integer". Math.round() automatically rounds it to the nearest integer. Then the second part says that if it is 0.6 then it should be rounded to 0 in which case we should use Math.floor(). I think the question is not clear and need to be rephrased to remove the word "nearest", until then, Math.round() is a right answer.

August Oliver
August Oliver
5,934 Points

The answer is: Math.floor( 5 / 2)

Math.floor(5 / 2) ;