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

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops `do ... while` Loops

Nicholas Wallen
Nicholas Wallen
12,278 Points

Why is there a 10 in the () at the top?

Why is this a 10?

var randomNumber = getRandomNumber(10);

The last video, which literally did the same thing, said "upper".

It would be extremely beneficial if he actually explained what each section of the code does (and also slows down).

1 Answer

Steven Parker
Steven Parker
229,744 Points

This is a very similar situation to what you asked about in your previous question. Most of the answer I gave you there would apply here also.

The only difference is that the argument being passed before was in the value of a variable ("upper"), and here the argument is being given as a literal number. In both cases the value (10 in this case) establishes the upper limit of the random number.