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 trialcuong Hoang
Courses Plus Student 735 PointscorrectGuess = false?
Hey guys just wondering, why does the syntax starts off with: correctGuess = false?
Can someone explain why the correctGuess variable is set to false before we begin?
2 Answers
Devin Scheu
66,191 PointsBecause if correct answer started as true the code would never run :), this is just clarifying that the variable is false to start with. :)
Bob Sutherton
20,160 PointsI omitted declaring it in the beginning of my program and it ran okay except that my else statement wouldn't execute. So, declaring that variable as false in the beginning is quite important indeed! Reading this thread actually helped me debug why my else statement wasn't firing.
hum4n01d
25,493 Pointshum4n01d
25,493 PointsYeah, thats right