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
Yacine Freifer
6,717 PointsRandom Number Challenge, Part II Solution
The console is saying: ncaught ReferenceError: isNan is not defined at getRandomNumber (randomNumberChallenge.js:7) at randomNumberChallenge.js:16
/This program allows you only to submit numbers and not strings. For strings it will return an error/
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(1,6)); console.log(getRandomNumber(5,10)); console.log(getRandomNumber(2,3)); console.log(getRandomNumber(9,5)); console.log(getRandomNumber(9,'fivehundered'));
2 Answers
Steven Parker
243,266 PointsJavaScript is case-sensitive, and the "isNaN" function is spelled with two capital "N"s. The error message is caused by the second one having a lower case "n" at the end.
KRIS NIKOLAISEN
54,974 PointsThe name of the function is case sensitive. It should be isNaN(). You have isNan(upper).