With these operations, we can easily condense the above code:
The above situations are fairly straight forward because we have a defined and known value that evalues to true or false. What happens though when you introduce values that could be truthy or fasly?
The same logic applies, one needs to be more careful though with the output. Remember, that many variables may be considered truthy depending on their type. Objects always evaluate to truthy even if they are empty.
So be careful if you are every checking against non-boolean objects! Make sure you know what the expected boolean output of that object is, it may not be what you think logically.
Here's a couple examples of things that come out to be truthy:
Some falsy objects:
Thanks for reading today!
Shoot me a message if you have any thoughts,
feedback, or criticisms. I would love to hear them.