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
Why is it that he didn't type var before correctGuess=true; in the first if statement?
Steven Parker224,836 Points
A variable can only be declared one time in a program.
On line 1 correctGuess is declared using var and initialized to false. Anywhere later in the program, like in the if statement, the variable can be reassigned by using only its name. It would be incorrect to declare it again.
Fritz-Patrick Atienza5,010 Points
The logic is that correctGuess wouldn't be true until the user types in the right number, so in all other cases, the guess would false.