Linas Jokubaitis
Linas Jokubaitis
4,162 Points

Could you remind me of what "upper" means and do? The word is written in function "randomNumber" parentheses.

function randomNumber(upper)

1 Answer

Osaro Igbinovia
Osaro Igbinovia
Full Stack JavaScript Techdegree Student 15,902 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

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.