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 Random Number Challenge, Part II Solution

Nour El-din El-helw
Nour El-din El-helw
8,241 Points

plz check my code

is there something wrong with my code??? https://w.trhou.se/wi8q3pvyha

Are you getting an error? If so, what does it say?

Nour El-din El-helw
Nour El-din El-helw
8,241 Points

That's what i get : Uncaught Error : check if all arguments are numbers random.js:3 at getRandomNumber (random.js:3) at random.js:9

1 Answer

It is doing exactly what you asked it to do. If one of the parameters is not a number then you throw an error saying "check if all arguments are numbers".

You are getting an uncaught error message because you throw this message but don't catch it.

If you put the code in a try catch block you will avoid this but it depends what the challenge is to do.