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 Create a random number

2 Answers

Matthew Lanin
seal-mask
.a{fill-rule:evenodd;}techdegree
Matthew Lanin
Full Stack JavaScript Techdegree Student 8,003 Points

From W3Schools.

Round a number downward to its nearest integer:

So, with the following,

Math.floor(4.6);

our expected output would be the nearest whole number that we can round down to, which in this case is 4.

The "floor" portion is actually just a property/method of the "Math" object, which has a bunch of inbuilt methods that you can use to do various things involving arithmetic.

Here's a list of methods you can use with the Math object. And don't worry about memorizing/knowing all of these, as long as you know they exist, you can go back to that page and find the methods that are useful for what you're trying to do at any given time.

:+1: Nice answer