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!

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


how does the number in getRandomNumber(###); work? Why is it multiplying it by the number?

Im use to doing this the first way it is written, im not entirely sure how the getRandomNumber(6); is the same thing? When you place an integer into the parenthesis is it automatically multiplied and why?

function getRandomNumber( upper ) { var randomNumber = Math.floor( Math.random() * 6 ) + 1; return randomNumber; }


function getRandomNumber( upper ) { var randomNumber = Math.floor( Math.random() * upper ) + 1; return randomNumber; }


2 Answers

It is some sort of witchcraft if you ask me.

currently searching the bible for the answer

Don't look in the bible. Try documentation on https://developer.mozilla.org/en-US/. All the answers are there. As a professional front-end developer you will be spending approx 80% looking through the documentation so you can get use to right now.