1 00:00:02,400 --> 00:00:05,070 OK, so let's take a look at the logical operators. 2 00:00:07,190 --> 00:00:14,040 This is mostly made up of the and or and not and these are just logic statements. 3 00:00:14,790 --> 00:00:22,150 So if X is true and Y is true, then ending them together is also true. 4 00:00:23,490 --> 00:00:28,230 If either X is true or Y is true, then using the order is true. 5 00:00:29,480 --> 00:00:35,300 So they both have to be false in that case for that X or Y to be false. 6 00:00:35,900 --> 00:00:44,150 So the end uses a double ampersand as its operator in the OR uses a double vertical bar and then the 7 00:00:44,150 --> 00:00:47,080 not uses an exclamation point as an operator. 8 00:00:47,090 --> 00:00:47,980 And it's unary. 9 00:00:48,770 --> 00:00:54,190 So it just says if X is true, not X is false and vice versa. 10 00:00:55,840 --> 00:01:02,970 So the immediate result of these is pretty simple, but you can have also very complicated expressions. 11 00:01:04,120 --> 00:01:08,370 So let's take a look at some of that and never believe I did. 12 00:01:08,380 --> 00:01:12,400 I made a copy of the starter sample application again. 13 00:01:12,850 --> 00:01:14,230 I think I'll stop saying it. 14 00:01:15,010 --> 00:01:18,480 So anyway, I did make a copy and we can do some logical operations here. 15 00:01:19,690 --> 00:01:23,390 So let's start with just using booleans. 16 00:01:24,310 --> 00:01:37,300 So if I say console log, true and true and let's come up with all the other possibilities 17 00:01:39,700 --> 00:01:48,910 so that I can say true and false, I could say false and true and then 18 00:01:51,550 --> 00:01:53,890 false and false. 19 00:01:54,130 --> 00:01:56,180 This is kind of known as a truth table. 20 00:01:56,890 --> 00:01:57,880 So what's the result? 21 00:01:57,910 --> 00:01:58,180 True. 22 00:01:58,180 --> 00:01:58,960 True, true. 23 00:01:58,960 --> 00:01:59,530 And false. 24 00:01:59,530 --> 00:02:00,460 False and true. 25 00:02:00,460 --> 00:02:01,230 False and false. 26 00:02:01,240 --> 00:02:02,890 Those are all the four possibilities. 27 00:02:06,190 --> 00:02:06,940 Let's run that. 28 00:02:09,380 --> 00:02:15,860 And only the first ones, true, because all of them have to be true and you're not limited just to 29 00:02:15,860 --> 00:02:21,430 operators to operands, I can also say and true again. 30 00:02:23,210 --> 00:02:29,990 And now I would have, I guess, nine possibilities, but we'll just list a couple of them. 31 00:02:35,950 --> 00:02:38,500 Oh, just shake it up a little bit. 32 00:02:38,970 --> 00:02:39,140 Now. 33 00:02:51,020 --> 00:02:52,700 So you can have as many as you want. 34 00:02:54,850 --> 00:02:58,190 You can say one plus two plus three plus four and go on for a long time. 35 00:02:58,600 --> 00:03:01,240 Same thing with us, you can say true and true and true and true. 36 00:03:01,900 --> 00:03:05,920 But with the end, all of them have to be true. 37 00:03:06,610 --> 00:03:12,520 Now, if we switch the ends to wars, that's going to be a different example. 38 00:03:14,470 --> 00:03:15,850 So let's see here. 39 00:03:21,640 --> 00:03:22,790 Two wars. 40 00:03:25,090 --> 00:03:25,780 All right. 41 00:03:36,140 --> 00:03:46,400 I can probably do this to find a replacement such as oil for lines and will I come at these old. 42 00:03:51,230 --> 00:03:54,050 Now, all of these are true, why? 43 00:03:54,060 --> 00:03:57,380 Because there's at least one thing in each one of these that's true. 44 00:04:00,070 --> 00:04:02,860 They can mix them up or is Anan's. 45 00:04:11,040 --> 00:04:12,710 Know it's come at this hour, 46 00:04:16,470 --> 00:04:17,530 so it's, uh. 47 00:04:20,300 --> 00:04:26,330 Replace the first one and just say, you know, operator process takes effect here, the end has more 48 00:04:26,330 --> 00:04:33,100 precedence than your first could do the first two first and then the order to the last one. 49 00:04:43,150 --> 00:04:48,760 True, if true, because we have true and true is true, true or true, it is true. 50 00:04:49,750 --> 00:04:55,540 Second one is false because true and false, false and false or false is also false. 51 00:04:56,980 --> 00:05:02,800 The third one is true because the first part is false, but the second part with the other is true. 52 00:05:03,490 --> 00:05:04,840 And same thing with the last part. 53 00:05:08,560 --> 00:05:12,320 And that we could take all this and nodded and come up with the opposite result. 54 00:05:23,300 --> 00:05:24,710 Let's come at these out 55 00:05:27,800 --> 00:05:35,450 and because of our presidents, I'm going to want to put parentheses around this, so we're going to 56 00:05:35,460 --> 00:05:39,980 start the whole thing and then I'll put the exclamation point here. 57 00:05:39,980 --> 00:05:45,140 Otherwise, we just not the first one that I want to, not the entire statement. 58 00:05:50,710 --> 00:05:56,990 The company at parentheses to the end of each of these. 59 00:05:59,840 --> 00:06:03,940 OK, what's what's uncommented. 60 00:06:03,950 --> 00:06:05,150 So you remember what it was. 61 00:06:10,800 --> 00:06:15,850 So the first part is true, false, true, true, and now we have false, true, false, false. 62 00:06:16,440 --> 00:06:19,150 So just reverse them. 63 00:06:21,210 --> 00:06:28,530 Now, all this is very simple with literal boolean values, but then you can start mixing in the variables 64 00:06:29,970 --> 00:06:32,310 and that starts complicating things. 65 00:06:34,380 --> 00:06:39,540 So the first thing I could do is let's let's just borrow one of these. 66 00:06:41,490 --> 00:06:42,680 Uh, maybe the first one. 67 00:06:48,900 --> 00:06:50,720 Is that going to replace all this? 68 00:06:54,150 --> 00:06:55,140 With variables 69 00:06:57,600 --> 00:07:12,690 and say what true value equals, true, but false value equals false and then never have true, I can 70 00:07:12,690 --> 00:07:15,570 just replace the with the variable. 71 00:07:27,980 --> 00:07:29,420 So they want to falsify. 72 00:07:34,450 --> 00:07:39,100 And so NASCAR took the variables instead of the literal, true and false, but we're going to come up 73 00:07:39,100 --> 00:07:40,030 with the same result. 74 00:07:45,130 --> 00:07:50,000 True, false, false, false, because it's an end and only the first one has Ultra's. 75 00:07:51,400 --> 00:07:55,330 Now, to complicate things even further, let's come into South. 76 00:07:57,170 --> 00:08:04,040 You can combine this with the relational operators and say something like this, and I'm not going to 77 00:08:04,160 --> 00:08:07,640 get as complicated because we have lots of examples moving forward. 78 00:08:08,400 --> 00:08:12,680 I to say let opper one equals five. 79 00:08:13,700 --> 00:08:17,750 Let Opper two equals seven. 80 00:08:19,430 --> 00:08:25,960 Let Opper three equals hello. 81 00:08:27,920 --> 00:08:29,260 And then I can say something like this. 82 00:08:29,270 --> 00:08:33,230 I can say if I say f sorry I'm getting out of myself. 83 00:08:33,980 --> 00:08:37,430 Consider log opper. 84 00:08:37,550 --> 00:08:48,320 One is less than five sorry for two or opper three 85 00:08:51,230 --> 00:08:52,790 equals triple equals 86 00:08:56,540 --> 00:08:58,720 hello with Litoral. 87 00:09:03,140 --> 00:09:09,800 So this could be true because five is less than seven and three equals. 88 00:09:09,800 --> 00:09:10,220 Hello. 89 00:09:12,160 --> 00:09:13,670 So let's just run it real quick. 90 00:09:18,350 --> 00:09:24,990 How about if we change this, to offer one is greater than OP or two and. 91 00:09:29,360 --> 00:09:30,710 Opera three equals hello. 92 00:09:31,550 --> 00:09:35,660 Well, the first parts can be false, but the second parts can be true. 93 00:09:40,090 --> 00:09:41,540 So the entire thing is going to be false. 94 00:09:42,280 --> 00:09:46,680 So these things can be combined in countless combinations. 95 00:09:47,950 --> 00:09:51,480 So we're going to see a lot of examples moving forward, especially when we get the conditionals. 96 00:09:51,490 --> 00:09:57,910 I already said the word F. So when we get the conditionals, we will see this used a lot more. 97 00:09:58,270 --> 00:10:03,340 Next up, we'll look at the last operator we're going to look at, which is the assignment operator.