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 trialRobert Bailey
UX Design Techdegree Student 5,089 PointsExplain this word ( Upper ) in this function please.
Function getRadomNumber( upper ) { var randomNumber = Math.floor( Math.random() * upper ) + 1; return randomNumber; } console.log( getRandomNumber(6) );
In the video, I have no clue where this "upper" word came from, what it does and how it relates to the function. Can someone explain this to me?
1 Answer
Calin Bogdan
14,921 PointsHello!
upper is the parameter you give to the function to determine the range the random number is picked from.
For example getRandomNumber(6) will return a random number between 0 and 6, getRandomNumber(10) will return a random number between 0 and 10 and so on.
Hope it helped!