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 trialAndrea Boscolo
7,250 PointsIn the IF at the end why I don't need do specify correctGuess === true;?
In the IF at the end why I don't need do specify correctGuess === true;?
2 Answers
andren
28,558 PointsBecause conditional statements like if
runs based on whether the value they are given evaluates to the Boolean true
.
When you compare two values that comparison actually produces a Boolean value. true
if the comparison is correct and false
if it isn't. That means that the comparison correctGuess === true
would actually produce the boolean true
if correctGuess
stored true
and false
if it stored false
.
So comparing correctGuess
to true
would result in the exact same value that is already stored within it. Making the comparison pointless.
Andrea Boscolo
7,250 PointsThanks! your explanations are always great!