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.

JavaScript JavaScript Basics (Retired) Creating Reusable Code with Functions Giving Information to Functions

Completely stumped by this question

I've watched the video twice but it just isn't happening for me.

Complete the code below to call the function and pass the value 12 to it:

function getRandom( upper )  {
   return Math.floor(Math.random() * upper) + 1;

All you need to do is replace parameter variable with the number 12 in the function. when you call the function.

4 Answers

Markus Ylisiurunen
Markus Ylisiurunen
15,034 Points

Hi Russel!

I think it just wants you to call the function with the value 12.

function getRandom( upper ) { 
    return Math.floor( Math.random() * upper ) + 1; 


Thanks Marcus. The thing is I tried that answer!

can you post your code, so we can see what the issue is then. please?

For anyone else who is using the code getRandom(12); Remove the semicolon from the end. There is already a semicolon provided in the question which is why the error is occurring. Pretty frustrating I wasted time on this question!

Wow really in the video I could of sworn he use a semicolon at the end. I've been stuck on this question for the past 4hrs re-watching videos trying to figure out where I went wrong. Thank you for tip

Ok I figured out I was typing it wrong... had getRandom (12); Wasn't meant to have a space after the function!

Simon New
Simon New
4,300 Points

Ha, unbelievable... I made exactly the same mistake and was so confused as to why it wasn't right! Thanks, this Q/A saved me from further frustrations.