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 Loops, Arrays and Objects Simplify Repetitive Tasks with Loops The Refactor Challenge

Alex Lang
Alex Lang
1,110 Points

so basically can someone explain math.random and math.floor?

Just need some explaining on this, I never got how those worked

3 Answers

MDN on Math.random and Math.floor

The Math.floor() function returns the largest integer less than or equal to a given number. So for instance Math.floor(3.2) will return 3. Not to get too confusing, anything in the 3 range will return turn so Math.floor(3.9) will still return 3. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new

Ben Hernandez
Ben Hernandez
3,578 Points

Math.random returns a floating-point number between 0 and 1. It includes 0, but not 1.