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 trialDwayne Sauls
1,279 PointsWhat does this mean "var randomNumber = Math.floor( Math.random() * 6) + 1; "
So I understand that it gets a random number but random number up until how far up until does it randomize....sorry I forgot. And understand the rounding of , of what floor means then its times that value with six. Then the plus one to get the random number only above zero.
1 Answer
David Schriever
1,777 PointsWhat is it exactly, what you don't understand?
Math.Random() creates a random number between, 0 and 0.9999999 time this by 6 and you will always get a number between 0 and 5, if you use Math.floor. Then you add +1 because you don't want a number between 0 and 5, but 1 and 6
Dwayne Sauls
1,279 PointsDwayne Sauls
1,279 PointsAwesome. Thanks! David Schriever
David Schriever
1,777 PointsDavid Schriever
1,777 Pointsno probs :-)