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.

Elizabeth Eymann
12,196 PointsRandom 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.
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
28,538 PointsYou 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
.