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 Basics (Retired) Creating Reusable Code with Functions Review: Giving Information to Functions

Piotr Połaniecki
PLUS
Piotr Połaniecki
Courses Plus Student 3,181 Points

What am I doing wrong?

In a quiz I had to finish a code:

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

to call the function and pass an argument (12) to it. So I did it in this way:

getRandom (12);

It's wrong. Why? Please light me up...

5 Answers

Bogdan Cabaj
Bogdan Cabaj
16,349 Points

You have a space between getRandom and (12) . Should be getRandom(12) ???

changed from comment to answer

Piotr Połaniecki ,

I selected "best answer" for you.

Bogdan Cabaj
Bogdan Cabaj
16,349 Points

You are including a semicolon in the text box where a semicolon is already included at the end. The only thing you need is getRandom(12).

Piotr Połaniecki
PLUS
Piotr Połaniecki
Courses Plus Student 3,181 Points

Thanks,

I already erased "my" semicolon and it still does not work...

Yeah, it looks like the quiz is not allowing a space there but it would be fine on a real project.

Piotr Połaniecki
Piotr Połaniecki
Courses Plus Student 3,181 Points

Hi Bogdan, please rewrite your comment as an answer so I can give you "best answer". Cheers.

Piotr Połaniecki
PLUS
Piotr Połaniecki
Courses Plus Student 3,181 Points

Thanks guys,

You're right although it's strange because in previous videos Dave have used spaces. I compared my work with his work in Workspaces and everything was fine. Never mind, I passed the quiz anyway, I was just curious. Wish you all the best. Piotr

Abdi Nur
Abdi Nur
3,802 Points

just completed this quiz, seems getRandom(12); worked for me.

all the best.