1
00:00:00,580 --> 00:00:06,490
All right, welcome back here on lesson seven, boolean logic, Boolean is named after a man, George

2
00:00:06,490 --> 00:00:06,800
Bush.

3
00:00:06,850 --> 00:00:12,970
He was an old mathematician in the eighteen hundreds and he really kind of defined the terms that we

4
00:00:12,970 --> 00:00:15,460
have for logic.

5
00:00:15,550 --> 00:00:20,860
And that's used a lot in mathematics and use fantastically in programming.

6
00:00:20,870 --> 00:00:22,880
It's used all over the place in programming.

7
00:00:23,260 --> 00:00:30,870
Basically, he invented and worked on very primitive computers and algebraic problems, boolean logic.

8
00:00:31,000 --> 00:00:33,730
So a couple of different operators we have.

9
00:00:33,730 --> 00:00:40,330
And and that's and that means both of the values to the left and right of this operator have to be true

10
00:00:41,530 --> 00:00:49,350
or means if one of the values or both to the left and right of this are true, it will continue.

11
00:00:49,510 --> 00:00:53,620
The exclamation mark is usually is paired with other operators.

12
00:00:53,620 --> 00:00:57,430
So like exclamation equals would be not equals.

13
00:00:57,430 --> 00:01:00,820
As you can see here, we're not exactly equal to.

14
00:01:01,860 --> 00:01:06,630
And then you have these others as well, these are other comparison operators, this is similar to work

15
00:01:06,630 --> 00:01:11,130
in Group two or the exactly the same as this is the same value and data type.

16
00:01:12,180 --> 00:01:15,480
This is less then and less than or equal to the left.

17
00:01:15,500 --> 00:01:21,060
Carrott right is right here is greater than greater than or equal to.

18
00:01:21,090 --> 00:01:24,210
So the value on the left is greater than the value on the right.

19
00:01:24,510 --> 00:01:26,460
And they have some bitwise operators.

20
00:01:26,760 --> 00:01:28,440
We can look at these as well.

21
00:01:28,440 --> 00:01:36,630
We don't use bitwise operators very often in JavaScript, but there they operate on a bit string, a

22
00:01:36,630 --> 00:01:39,990
bit array or binary numeral at the level of individual bits.

23
00:01:40,650 --> 00:01:45,870
So it's it's kind of what computer programming does at a more basic level.

24
00:01:46,230 --> 00:01:48,960
And you can perform those on binary numbers as well, too.

25
00:01:49,680 --> 00:01:52,620
OK, so let's take a look at some values in code.

26
00:01:54,810 --> 00:01:59,680
All right, so now in JavaScript, let's just focus on some of the ones we use most most often.

27
00:01:59,700 --> 00:02:07,410
So let's just say let the equation equal five is greater than two.

28
00:02:12,050 --> 00:02:17,450
And so we could just check to see, is this true, so we could just along the variable itself

29
00:02:20,510 --> 00:02:25,070
equation and then we'll see, hey, is five greater than two?

30
00:02:26,240 --> 00:02:27,860
And the answer is yes, it is true.

31
00:02:29,290 --> 00:02:34,510
Now, if we check, is it less than two, that's false.

32
00:02:34,630 --> 00:02:38,980
Five is not less than two, is it less than or equal to two?

33
00:02:40,780 --> 00:02:41,770
No, that's false.

34
00:02:42,280 --> 00:02:44,560
Is it less than or equal to five?

35
00:02:46,170 --> 00:02:53,160
Yes, five is less than or equal to five, because five is equal to five is five less than five.

36
00:02:53,700 --> 00:02:55,390
No, that's false.

37
00:02:56,040 --> 00:03:01,110
So you could say you could use these comparison operators to check something less than or less than

38
00:03:01,110 --> 00:03:02,040
or equal to something.

39
00:03:02,220 --> 00:03:09,120
And then you can use five is greater than two and

40
00:03:12,150 --> 00:03:13,620
two is greater than one.

41
00:03:14,340 --> 00:03:16,110
OK, so let's just see how this goes.

42
00:03:18,160 --> 00:03:19,710
Let's just read this right now.

43
00:03:21,610 --> 00:03:22,090
True.

44
00:03:22,300 --> 00:03:24,790
OK, so five is greater than two, that's true.

45
00:03:25,630 --> 00:03:26,650
Two is greater than one.

46
00:03:26,680 --> 00:03:27,340
That's true.

47
00:03:27,340 --> 00:03:33,190
Also, OK, these are both true and this says both have to be true.

48
00:03:33,220 --> 00:03:35,460
And so this is true.

49
00:03:35,500 --> 00:03:38,800
And this is true.

50
00:03:39,700 --> 00:03:43,990
So if we change this one to four and we check it again.

51
00:03:45,250 --> 00:03:50,980
It's false because, too, is not greater than four, so since this site is true, this site is false,

52
00:03:51,430 --> 00:03:54,860
it's true and false, which means the total is false.

53
00:03:55,010 --> 00:03:57,790
There's any false value in there, then the whole thing is false.

54
00:03:58,120 --> 00:04:02,530
OK, because that's the final value that's being checked.

55
00:04:02,650 --> 00:04:03,210
Rechecking, checking.

56
00:04:03,220 --> 00:04:03,860
Is this true?

57
00:04:03,880 --> 00:04:04,270
Yes.

58
00:04:04,720 --> 00:04:06,310
And is this true now?

59
00:04:06,490 --> 00:04:08,650
OK, so are they both true?

60
00:04:09,070 --> 00:04:10,650
No, that's the real question.

61
00:04:11,470 --> 00:04:20,480
Now, if he chooses to or then one of them being true is OK, as you can see, that's true.

62
00:04:21,190 --> 00:04:23,080
What if we make them both false?

63
00:04:23,310 --> 00:04:30,460
OK, we make them both false, then boom, neither one is false or is asking.

64
00:04:30,640 --> 00:04:32,530
Is at least one of these true?

65
00:04:33,060 --> 00:04:34,220
That's what Gore is asking.

66
00:04:34,620 --> 00:04:41,590
OK, so that's how you get and and or there's also not we can say this

67
00:04:44,620 --> 00:04:47,860
five equals five.

68
00:04:49,870 --> 00:04:52,520
OK, is that true.

69
00:04:52,630 --> 00:04:53,230
Yes.

70
00:04:53,240 --> 00:04:54,460
Five is equal to five.

71
00:04:55,310 --> 00:04:58,810
You can also do ten divided by two is five.

72
00:04:58,810 --> 00:05:00,220
Exactly the same is ten.

73
00:05:00,220 --> 00:05:01,080
Divided by two.

74
00:05:01,210 --> 00:05:03,270
Yes, because ten divided by two is five.

75
00:05:03,940 --> 00:05:06,550
What if we say is not equal to.

76
00:05:07,130 --> 00:05:07,930
Let's check that.

77
00:05:08,270 --> 00:05:10,100
No, that's false.

78
00:05:10,120 --> 00:05:12,880
Five is not not equal to five.

79
00:05:13,480 --> 00:05:17,710
So let's try again with let's change this value to four.

80
00:05:19,270 --> 00:05:22,720
Is four different then.

81
00:05:22,720 --> 00:05:23,770
Ten divided by two.

82
00:05:25,170 --> 00:05:27,520
Yes, the answer is true.

83
00:05:28,080 --> 00:05:28,600
There you go.

84
00:05:29,280 --> 00:05:37,410
So that's how you can use equals to say is the same as not equals with the not symbol to say is not

85
00:05:37,410 --> 00:05:38,220
the same as.

86
00:05:39,540 --> 00:05:41,130
OK, just beware.

87
00:05:41,130 --> 00:05:47,250
Obviously, you might have gotten a little tripped up when I was saying, hey, is this not the same

88
00:05:47,250 --> 00:05:48,120
as the other thing.

89
00:05:48,120 --> 00:05:56,520
And you say yes or no humans, especially in English, have a hard time asking and answering questions

90
00:05:56,520 --> 00:06:02,520
which involve not only is this not the same, what are you supposed to say to that?

91
00:06:02,530 --> 00:06:03,240
Yes or no?

92
00:06:03,990 --> 00:06:10,770
So we keep it simple in JavaScript, true or false, but still beware of using not just so you don't

93
00:06:10,770 --> 00:06:12,540
get confused with what you need to do.

94
00:06:12,820 --> 00:06:13,950
OK, all right.

95
00:06:13,960 --> 00:06:21,270
So that is the basics of boolean logic in JavaScript and we'll catch you in the next video.
