1
00:00:00,170 --> 00:00:09,470
The next type of operator is logical operators, and it involves these types.

2
00:00:09,590 --> 00:00:13,250
So what are logical operators?

3
00:00:13,640 --> 00:00:23,000
These are used to combine conditional statements and evaluate multiple conditions in order to determine

4
00:00:23,000 --> 00:00:24,830
the final outcome.

5
00:00:25,310 --> 00:00:29,360
Let's get back to code in that way, you better understand.

6
00:00:29,660 --> 00:00:39,560
I'm going to provide the comment as logical operators and let me copy this and down here.

7
00:00:40,710 --> 00:00:46,680
I will paste that and it's going to be logical operators.

8
00:00:47,070 --> 00:00:51,960
And the first type is called the and operator.

9
00:00:51,990 --> 00:00:54,780
That is the double ampersand.

10
00:00:55,290 --> 00:01:06,840
Let me provide the definition as that the logical and operator returns true if both operands are true.

11
00:01:07,110 --> 00:01:10,170
Otherwise it will returns false.

12
00:01:10,530 --> 00:01:13,380
Let's have some case study here.

13
00:01:14,240 --> 00:01:21,410
Let's say that you want to decide whether to go to the park based on two conditions.

14
00:01:21,530 --> 00:01:25,520
If it is sunny or warm outside.

15
00:01:26,060 --> 00:01:32,230
So let's go ahead and solve this case study using the and operator.

16
00:01:32,240 --> 00:01:34,670
That is the double ampersand.

17
00:01:35,410 --> 00:01:38,590
Let's declare a variable called a sunny.

18
00:01:39,990 --> 00:01:43,110
And by default, you will say true.

19
00:01:43,890 --> 00:01:48,150
And also let's declare a variable called a swarm.

20
00:01:50,420 --> 00:01:53,540
And you assign true to it.

21
00:01:54,230 --> 00:01:56,330
So we are going to check.

22
00:01:56,920 --> 00:02:05,680
If these two conditions are true, therefore, we are going to declare a variable as should go to park.

23
00:02:06,460 --> 00:02:17,530
And is going to be as this equal to a sunny, then double ampersand and then is warm.

24
00:02:18,610 --> 00:02:25,240
So and operators always check if all the conditions are true.

25
00:02:25,330 --> 00:02:29,690
If one is false, then it's going to return false.

26
00:02:29,710 --> 00:02:32,860
With this one, what will be the result?

27
00:02:32,890 --> 00:02:38,980
Let's check inside our console and let's set for should go to park.

28
00:02:39,070 --> 00:02:41,080
And it is true.

29
00:02:41,410 --> 00:02:50,860
If I change this one to false, the result will be false because one condition is false.

30
00:02:51,220 --> 00:02:56,020
The next operator is logical or operator.

31
00:02:56,260 --> 00:02:58,510
And this is the symbol.

32
00:02:58,870 --> 00:03:02,080
Let's have the definition for that.

33
00:03:02,610 --> 00:03:04,560
And it goes like this.

34
00:03:04,770 --> 00:03:15,360
The logical or operator returns true if either or both of the operands are true and it returns false

35
00:03:15,390 --> 00:03:18,510
only if both operands are false.

36
00:03:18,810 --> 00:03:28,500
For this one, it will only check if one condition is true and the remaining are false, then it will

37
00:03:28,500 --> 00:03:29,940
return true.

38
00:03:30,520 --> 00:03:36,100
But if all the conditions are false, then it will return false.

39
00:03:36,520 --> 00:03:44,710
So let's have some case study and I'm going to paste it down here as that.

40
00:03:45,130 --> 00:03:52,270
It says that you want to check if it is not raining so that you can go outside.

41
00:03:52,830 --> 00:03:57,900
We are going to declare a variable as let is raining.

42
00:03:59,310 --> 00:04:02,490
And by default is false.

43
00:04:03,860 --> 00:04:11,570
And let's also check if is snowing and we will say true.

44
00:04:12,450 --> 00:04:13,620
For this one.

45
00:04:13,620 --> 00:04:24,180
Let's declare a variable called result and we are going to check if it is raining or is snowing.

46
00:04:24,510 --> 00:04:26,220
What will be the answer?

47
00:04:26,250 --> 00:04:30,990
Let me comment out this or remove this variable name here.

48
00:04:31,350 --> 00:04:33,030
What will be the answer?

49
00:04:33,180 --> 00:04:36,450
Let's check inside the console here.

50
00:04:36,450 --> 00:04:41,520
And it is true because one condition is true.

51
00:04:41,640 --> 00:04:52,920
But if we change this one to false, let's have a look and we have false as the result and we can add

52
00:04:52,920 --> 00:04:53,850
more conditions.

53
00:04:53,850 --> 00:05:06,330
So let's say let is nine, then we will say true or let me say false and we can add all operators and

54
00:05:06,330 --> 00:05:14,320
it's night Since all of these ones are false, we're going to have false as the return value.

55
00:05:14,620 --> 00:05:20,560
But if one of these is true, then it's going to return true.

56
00:05:20,740 --> 00:05:24,790
It's supposed to be result this one.

57
00:05:24,970 --> 00:05:29,560
So that is the logical operators for you.

58
00:05:29,980 --> 00:05:33,850
The last operator is the string operators.

59
00:05:33,880 --> 00:05:35,950
Let's continue in the next video.

