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 trialvikrant kaushal
Front End Web Development Techdegree Student 2,558 Pointsconfused with teachers note ?
Can someone please explain the video and teachers note better getting confused with isNan() second time watching the video please that will help if someone broke it down really good
3 Answers
Mark Sebeck
Treehouse Moderator 37,905 PointsHi Vikrant. isNan() is a Javascript function that tells you if something is NOT a number. If you pass it a number it will return false because a number is "not" not a number. If you pass it a string or anything other type it will return true because strings and other types are not numbers.
aNumber = isNan(6);
aNumber = isNan("Vikrant")
In the first example aNumber will equal false because 6 is a number (or "not" not a number) In the second example aNumber will equal true because "Vikrant" is a string not a number.
Mark Sebeck
Treehouse Moderator 37,905 PointsIn the video Guil uses parseInt to convert the string to an int. parseInt will return the integer number or NaN if its not a number. The if statement uses the value returned from parseInt. So its going to be a number or NaN if its not a number. Any value 1 or greater will evaluate to true in the if statement and NaN will evaulate to false. So "if(1)" would be true. The problem is if zero is entered the if statement will fail like its not a number because zero is evaluated to false.
So in the teachers note they use the isNaN function to check:
if ( isNaN(lowNumber) || isNaN(highNumber) ) {
console.log('You need to provide two numbers. Try again.');
} else { .......
}
so in plain English this say "if lowNumber is not a number OR highNumber is not a number THEN tell the user 'You need to provide two numbers. Try again.' "
Hope this helps make it less confusing.
vikrant kaushal
Front End Web Development Techdegree Student 2,558 PointsYes when you. Broke it to plain English so much more, thank you so much any tips for a non coder because first time coding and I'm doing full stack development track with html,css,js any tips will please and thank you
Mark Sebeck
Treehouse Moderator 37,905 PointsI would say that the html, css and javascript track is a great place to start for a true beginner. It's going to take time, don't try to rush it. Watch the videos several times if something doesn't make sense and ask questions in the Community. There are a lot of friendly students, teachers and moderators that will help. Also look in the teacher notes (great that you are). There are a lot of useful links in there. Read the documentation that the notes link to. And build your own little projects in Workspaces. Workspaces is a great place to practice.
Good luck. So glad you are here and are eager to learn.
vikrant kaushal
Front End Web Development Techdegree Student 2,558 PointsThank you that explains it better but guil had did nan then passed a number is was true I was just in general confused with video, the explanation does help a little