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 trialJules Al
1,096 PointsisNaN is not defined
I'm trying to test my code to ensure I get my custom error message when entering a string as an argument for the randomNumber function. However, when I check the console, I keep getting an error stating isNaN is not defined. Can someone tell me why this is and how I can resolve this?
function randomNumber(upper, lower){
if(isNan(upper) || isNaN(lower)){
throw new Error('Both arguments must be numbers');
}else{
return Math.floor(Math.random() * (upper - lower + 1)) + lower;
}
}
alert(randomNumber("ten", 6));
alert(randomNumber(13, 9));
alert(randomNumber(100, 1));
1 Answer
Allison Walker
17,137 PointsYou have a typo for your first "isNaN". You wrote, "isNan".
Jules Al
1,096 PointsJules Al
1,096 PointsI knew it had to be something tiny I was overlooking. THANK YOU