Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Robert Bailey
Robert Bailey
UX Design Techdegree Student 5,089 Points

Explain 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
Calin Bogdan
14,921 Points


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!