Boolean: True/False Statements

Alexis Grisham
2 min readAug 6, 2018

--

If/else statements can be qualified in a few different categories. But the one we will focus on today is boolean:

If (something affects) {

something happens}

else {

this happens instead}.

This can be proved by two different qualifiers. And”&&” will return the value to be true only if both values are equally true. The or”||” will return true if only one of the values is true. {ex: if it is 75F outside AND it is sunny, it is TRUE that it is a beautiful day. If it is 75F outside OR it is sunny(not both need be met) it is TRUE that it is a nice day.} To put this in coding terms, we could not say [1] === “1” because the hard equality (===) reads that these are different types, a array and a string, and they are not equal. If we said [10] == “10” with the soft equality(==) that would read as true, because it doesn’t care what type they are.

Truthy/Falsy statements are another way of describing boolean values. “Truthy” is any non-zero number, any strings, or anything that is NOT falsy. Falsy statements are any that equal zero, are null, not a number, or empty strings.

The importance of this is easier to understand in lamens terms. If I am telling my Javascript code to run a certain function(ex: turn the background Blue) when certain conditions are met(user clicks certain button, while function”play song” is running in the background). Or else, the background will turn green if the user clicks the button while the song function is not running. Make sense?

--

--