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!
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
How does the program know that the highNumber variable is a number and execute the first if statement?
And if not the else statement is executed?
This got me for a sec too, but here's the solution:
Before he goes to the if statement, he's parsing the number from the user input via the parseInt() method.
The user either enters something that can be parsed into a number, or the parseInt() method returns NaN, which then evaluates to false.
Read more about why NaN evaluates to false and other falsy values here: https://developer.mozilla.org/en-US/docs/Glossary/Falsy