Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Brendan WhitingFront End Web Development Techdegree Graduate 84,678 Points
I don't understand why how logical expression evalutates
"If the variable isFiltered is false, what would the following expression evaluate to?
!isFiltered && 'showAll'"
I would have thought it was 'true', but it evaluates to 'showAll'. I don't understand why.
Nicholas Grenwalt46,626 Points
Logical AND will only return true for the second expression if it literally evaluates to such as in doing a comparison (true && 12 > 5 for example), otherwise it will return whatever the actual value is. The string 'showAll' is true under the hood yes, but logical AND returns the value of that truthy expression, not the boolean representation of that value. The same goes for True && 'cat' would return the string cat. Hope that helps.