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 trialLinas Jokubaitis
4,162 PointsCould you remind me of what "upper" means and do? The word is written in function "randomNumber" parentheses.
function randomNumber(upper)
1 Answer
Osaro Igbinovia
Full Stack JavaScript Techdegree Student 15,928 Points'upper' is a parameter that has been set when constructing the 'randomNumber' function. When calling the 'randomNumber' function you pass in an argument in its parenthesis, this argument is the value which is stored in the parameter. Think of a parameter(upper) as a variable and an argument(which you call with a function) as the value stored in that variable. Take for example:
// Constructing a function with a parameter
function randomNumber(upper) {
var addedNumbers = upper + 20;
return addedNumbers;
}
// Calling the function and passing in an argument
randomNumber(15);
The above snippet of code is basically the same as:
var upper = 15;
var addedNumbers = upper + 20;
They both add 15 and 20(which is 35) and store the value in the 'addedNumbers' variable.