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 Functions Arrow Functions Testing for Number Arguments

I am getting an error that isNAN is not defined, but my code is the exact same as the video.

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

console.log( getRandomNumber(1, 6));
console.log( getRandomNumber(10, 100));
console.log( getRandomNumber(200, 'three hundred'));

What is incorrect?

Mod edit: added markdown for code readability. Check out the "markdown cheatsheet" below the comment box for syntax examples.

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Alexis Scriven! It's very close to the video but not exactly like it :smiley: In two places you have typed: isNAN instead of isNaN. Note the lower case "a" instead of the uppercase "A" as you have it. This is all case-sensitive.

Hope this helps! :sparkles:

Ah, I see it now. Thank you for your help, Jennifer!

wildgoosestudent
wildgoosestudent
11,274 Points

I just had this issue too! Thanks for posting :)