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 trialDamjan Bozinovski
9,916 Pointshow do upper and lower take values?
a
2 Answers
Justin Cantley
18,068 PointsThey are parameters for when you call the function getRandomNumber. When you call the function, the numbers that you enter as arguments will be used as the values for upper and lower respectively.
For example, when Dave calls the function for the first time in the video he does it like so:
getRandomNumber(1, 6);
Here the value for lower will be 1 and the value for upper will be 6.
Justin Blalock
8,206 PointsYou could always let the user input the value with prompts as well for interactivity ( This is before input validation of course) :
var lower = prompt("Enter a number");
var upper = prompt("Enter a higher number");
document.write("<h2> " + getRandomNumber(parseInt(lower), parseInt(upper)) + "<h2> ");