The next type of operator is logical operators, and it involves these types.
So what are logical operators?
These are used to combine conditional statements and evaluate multiple conditions in order to determine
the final outcome.
Let's get back to code in that way, you better understand.
I'm going to provide the comment as logical operators and let me copy this and down here.
I will paste that and it's going to be logical operators.
And the first type is called the and operator.
That is the double ampersand.
Let me provide the definition as that the logical and operator returns true if both operands are true.
Otherwise it will returns false.
Let's have some case study here.
Let's say that you want to decide whether to go to the park based on two conditions.
If it is sunny or warm outside.
So let's go ahead and solve this case study using the and operator.
That is the double ampersand.
Let's declare a variable called a sunny.
And by default, you will say true.
And also let's declare a variable called a swarm.
And you assign true to it.
So we are going to check.
If these two conditions are true, therefore, we are going to declare a variable as should go to park.
And is going to be as this equal to a sunny, then double ampersand and then is warm.
So and operators always check if all the conditions are true.
If one is false, then it's going to return false.
With this one, what will be the result?
Let's check inside our console and let's set for should go to park.
And it is true.
If I change this one to false, the result will be false because one condition is false.
The next operator is logical or operator.
And this is the symbol.
Let's have the definition for that.
And it goes like this.
The logical or operator returns true if either or both of the operands are true and it returns false
only if both operands are false.
For this one, it will only check if one condition is true and the remaining are false, then it will
return true.
But if all the conditions are false, then it will return false.
So let's have some case study and I'm going to paste it down here as that.
It says that you want to check if it is not raining so that you can go outside.
We are going to declare a variable as let is raining.
And by default is false.
And let's also check if is snowing and we will say true.
For this one.
Let's declare a variable called result and we are going to check if it is raining or is snowing.
What will be the answer?
Let me comment out this or remove this variable name here.
What will be the answer?
Let's check inside the console here.
And it is true because one condition is true.
But if we change this one to false, let's have a look and we have false as the result and we can add
more conditions.
So let's say let is nine, then we will say true or let me say false and we can add all operators and
it's night Since all of these ones are false, we're going to have false as the return value.
But if one of these is true, then it's going to return true.
It's supposed to be result this one.
So that is the logical operators for you.
The last operator is the string operators.
Let's continue in the next video.