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 trialMartel Storm
4,157 PointsI don't understand why this statement is true. Can someone please elaborate?
(!true || !false) && (true && !false)
2 Answers
Steve Hunter
57,712 PointsHiya,
The first parentheses evaluate to true
. That's because you are comparing true
with false
using OR
. So, because one of the two comparators is true
, the whole parentheses evaluate to true
.
The second parentheses also evaluate to true
as you are comparing true
with NOT false
. So, you are comparing true
(first parentheses) with true
(second parentheses) using AND
, which evaluates to true
!
I hope that makes sense!
Steve.
andren
28,558 PointsThe !
operator essentially reverses a booleans so the first part is essentially this (false || true) since the || operator returns true if either of its conditions are true it will ultimately return true. So the expression on the left of the && operator is true. The expression on the right is essentially (true && true) and the && operator returns true if both of its conditions are true. So the result of the right expression is ultimately true.
That means that after unpacking the right and left expressions you end up with true && true
which as mentioned above resolves to true.
Martel Storm
4,157 PointsMartel Storm
4,157 PointsThis answers my question wonderfully! Thank you!
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsNo problem!