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 trialbaderbouta
7,804 PointsKinda' confused.
Hey,
I was wondering, why did Mark use an 'upper' argument when he constructed the function but then when he called that same function he actually used an 'integer'?
function getRandomNumber(upper) {
var randomNumber = Math.floor(Math.random() * upper) + 1;
return randomNumber;
}
console.log(getRandomNumber(7));
console.log(getRandomNumber(304));
console.log(getRandomNumber(345));
console.log(getRandomNumber(45546));
1 Answer
Jahanzeb Khan
226 Pointsyou can name upper anything its just an argument. you can change it to abc, integer etc they are just variables in the function scope. The below code will also work fine for you.
function getRandomNumber(integer) { var randomNumber = Math.floor(Math.random() * integer) + 1; return randomNumber; }
baderbouta
7,804 Pointsbaderbouta
7,804 PointsThank you Jahan, I've just learned that they are just 'placeholders' for the arguments (which are called parameters), thank you.
Jahanzeb Khan
226 PointsJahanzeb Khan
226 PointsYes, that is better phrasing for this. Thanks for letting me know.