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 trialNeil Bircumshaw
Full Stack JavaScript Techdegree Student 14,597 PointsDon't quite understand the last part of the problem.
So I understand everything except this part...Math.floor(Math.random() * (topNumber - bottomNumber + 1)) + bottomNumber;
I'm unsure why one variable is being subtracted from another. I understand you put +1 because of the Math.floor needs that, but then why do you then add the bottomNumber variable again.
Cheers guys, sorry if it sounds like a silly question :)
1 Answer
Chris Davis
16,280 PointsHere is a discussion on that very topic Hope it helps :)
https://teamtreehouse.com/community/mathfloor-mathrandom-max-min-1-min-explanation
Jason Anello
Courses Plus Student 94,610 Pointschanged from comment to answer
Neil Bircumshaw
Full Stack JavaScript Techdegree Student 14,597 PointsNeil Bircumshaw
Full Stack JavaScript Techdegree Student 14,597 PointsPerfect! It's clicked, I had to get my pen and paper out to make sense of it after then reading one of the very good answers on there. Don't think it was explained in good detail at all in the video. I would say this needs re-doing to be explained more thoroughly, it was kind of just throw at you, expecting you to know what was going on.
Thank you so much for your post my friend :)