Imagine you're back in middle school, and your team just won your hometown Little League baseball series. High off of the adrenaline from riding the bench while your star teammate hit the game-winning home run, your parents decide to treat you to some ice cream!
You go up to the counter and say, "I'd like vanilla, and for my topping I'll take either gummy worms or rainbow sprinkles. Whichever is your favorite."
When you stated that you wanted "gummy worms OR rainbow sprinkles", you exemplified that you only need one of those toppings to be on your ice cream to be happy. Doesn't matter if you only get gummy worms, rainbow sprinkles, or both, you'll be happy.
OR defines two or more conditions and returns true if any of them are true. It will only return false if both the conditions are false.
Let's the above scenario to an Excel worksheet to exemplify how we could accomplish it with actual code.
Below is the template for OR functions:
=OR(logical1, [logical2], ...)
For our second order, we said we wanted either gummy worms or rainbow sprinkles. These toppings are in cells A5 and A2 (respectively). Considering our resulting toppings are in cells D6 and E6, we'd write our OR function like so:
We're stating here that our first topping (D6) needs to be Gummy Worms (A5)...
...or our second topping (E6) needs to be Rainbow Sprinkles (A2) in order for us to be happy with our order.
When we code this, we get the following result:
It is false right now because we have not entered our result in yet. Let's do that now.
Did you notice how our OR function in cell D7 returned true right after we entered the first topping? This is because we didn't even need to enter the second topping to be happy with our order. We had already received one of our desired toppings... meaning that one of our conditions was true. With OR statements, only one of the conditions must return true for the entire function to return true!