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

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; }

console.log(getRandomNumber());


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

console.log(getRandomNumber(6));

2 Answers

currently searching the bible for the answer

Piotr Manczak
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Piotr Manczak
Front End Web Development Techdegree Graduate 29,104 Points

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.