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

Random number challenge 2

Hello,

I'm having a hard time understanding what I did wrong here. I followed Dave's example in completing the random number challenge 2 in JavaScript Basics, but when I go to the web console I get a message saying "reference error: isNan is not defined". I can't see what I'm doing differently from the example given. Can anyone help? Here is my code and here is a snapshot of my workspace if that is easier to read. Thank you.

https://w.trhou.se/ywyi6ehnbj

function getRandomNumber( lower, upper ) { if ( isNan(Lower) || isNaN(upper) ) { throw new Error('Both arguments must be numbers'); } return Math.floor(Math.random() * (upper - lower + 1)) + lower; }

console.log( getRandomNumber( 'nine', 24 ) ); console.log( getRandomNumber( 1, 100 ) ); console.log( getRandomNumber( 200, 'five hundred' ) ); console.log( getRandomNumber( 1000, 20000 ) ); console.log( getRandomNumber( 50, 100 ) );

1 Answer

andren
andren
28,558 Points

You have two typos in your code. Both related to differences in capitalization. JavaScript along with most programming languages is case-sensitive, meaning that Hello and hello are two entirely different words as far as it is concerned.

Specifically your typos are that the isNaN function ends with a capital N not a lowercase one like you use. And you also pass the first isNaN function an argument of Lower which should be lower with a lowercase letter to match the parameter named lower.