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
chuck kotulka
4,583 Pointsquestion about functions and variable decelerations. Anyone?
I understand the Math.random command but I am unclear to what the upper refers to in the function? is that like the Math.ceil?
function randomNumber(upper)
second part of question.
can someone please explain the variable deceleration?
var randNnum = randomNumber(6);
1 Answer
Steven Parker
243,266 PointsThe "upper" shown above is simply a parameter name and has no special meaning to the language. But as a common "best practice" the name was chosen to relate to what the variable will be used for, and in this case it will be the upper bound of the range for which a random number will be generated.
I think you mean "declaration" ("deceleration" means "slow down"), and the declaration part is simply the keyword "var" followed by the name of the variable that is being created. The statement shown is more than a simple declaration, since a value is also being assigned at the same time. Declaring and assigning a variable in one statement is also known as "initialization". In this case, the value being assigned comes from calling the "randomNumber" function and passing it the value "6" (which will cause it to return a random value that won't be higher than 6).