Conditional Operators
Learn about the conditional operators with the help of an example in this lesson.
We'll cover the following
These operators perform the operations on two Boolean expressions. Conditional AND and Conditional OR are represented by these two symbols &&
and ||
symbols, respectively.
There are some golden rules in such operations. Because two Boolean expressions are involved, they could either be true
or false
. You need to remember that here the Conditional-AND represents some kind of mixing. On the other hand, Conditional-OR represents a kind of separation.
You can also think of true
as a good guy and false
as a bad guy.
What would happen when two good guys got together? Something good would come up. Right? So, the Boolean expression true
and true
always come out true
.
On the contrary, when a good guy mixes with a bad guy, what happens? The good guy no longer remains good. Right? So, true
and false
come out false
. However, when we say, true
or false
, as a rule, the good guy separates himself from the bad guy. So, the result comes out true
.
Get hands-on with 1400+ tech skills courses.