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 Basics (Retired) Making Decisions with Conditional Statements Improving the Random Number Guessing Game

Zoe Campbell
Zoe Campbell
6,288 Points

If all guesses are wrong and correctGuess stays false is the last if statment not saying correctGuess is false?

If all guesses are wrong and correctGuess stays false is the last if statment not saying correctGuess is false? Meaning if the two chances to guess still fail correctGuess never becomes true meaning the last if statment means correctGuess is false and so would say the answer is correct if all guesses are wrong?

Steve Gallant
Steve Gallant
14,943 Points

If the two chances to guess are wrong, you are correct that correctGuess remains "false". The last if statement tests the condition if correctGuess is "true"...if it is, it displays the success message. If not, the "Sorry..." message will be written.