You can use a compound statement if you want to make sure that two or more conditionals are true or not before executing the associated block of code. Let’s take a look at an example:
In the example above, we have two booleans, cleanedRoom and didHomework. && can be used to check if BOTH variables are true. If and only if they are both true, then the code inside the if-block runs.
But what if we don’t want to be as strict? What if we want the code to run if one of them is true, or if both are true? We instead use || (OR) as below.
We can also use && and || to check for numeric values and combine them with other operators (<, >, >=, <=, etc) to create complex checks.
Sometimes we’ll want to negate a boolean. So it’s easier to say, if this is NOT true, then go ahead and run the code. This can get quite tricky, so it’s very important to name your variables well.