1 00:00:01,290 --> 00:00:02,100 What's up, guys? 2 00:00:02,250 --> 00:00:09,960 Welcome to another lecture here, are we going to learn about a logical operators and arithmetical operators 3 00:00:09,960 --> 00:00:17,910 like math operators that we can use here in JavaScript, like plus minus division in times and also 4 00:00:17,910 --> 00:00:21,780 greater and than there are called logical operators. 5 00:00:21,780 --> 00:00:30,270 So they're not only basic arithmetic operations that we can do, we can do something even more powerful 6 00:00:30,270 --> 00:00:30,960 and logical. 7 00:00:31,260 --> 00:00:34,330 For that reason, I just don't want to continue here working. 8 00:00:34,350 --> 00:00:41,040 So what I want to do, I'm just going to copy this index and I'm going to name it and I'm going to say 9 00:00:41,280 --> 00:00:45,660 operators, operators, not HTML. 10 00:00:45,660 --> 00:00:47,790 I'm just going to close this one. 11 00:00:48,790 --> 00:00:50,400 I mean, cut that one. 12 00:00:50,880 --> 00:00:53,600 And I really don't need all of these. 13 00:00:53,910 --> 00:01:02,490 So to make sure that you need rename it to operators, the HDMI, save it now I'm just want to create 14 00:01:02,490 --> 00:01:06,150 an additional JS file called operators. 15 00:01:06,150 --> 00:01:11,280 That genius is that operators of genius will be linked here. 16 00:01:14,050 --> 00:01:20,200 Sorry, yeah, oops, operators are just so script. 17 00:01:20,410 --> 00:01:30,520 Yes, we don't need it anymore, and now we can work with this one and we can just see, OK, operators, 18 00:01:30,520 --> 00:01:37,110 JavaScript, fundamental, logical and math operators. 19 00:01:38,890 --> 00:01:42,520 Maybe we should do the same thing for each and every one, but it doesn't matter now. 20 00:01:42,520 --> 00:01:46,270 We are here and we can do a couple of things here. 21 00:01:46,270 --> 00:01:53,920 And what I want you to do is I would like to jump a little bit in future. 22 00:01:54,070 --> 00:01:57,850 So I'm going to create some function here because I don't know when you're going to see this lecture, 23 00:01:57,850 --> 00:02:00,880 maybe in future, like a year or two years from now. 24 00:02:01,180 --> 00:02:05,350 And I don't want to be boring in 2020 here. 25 00:02:05,560 --> 00:02:08,280 And you can see in 2022 over there. 26 00:02:08,290 --> 00:02:08,600 Right. 27 00:02:08,770 --> 00:02:14,210 So I'm just going to use the date function, word date, and that will be cool. 28 00:02:14,230 --> 00:02:14,730 New date. 29 00:02:14,740 --> 00:02:15,760 Don't worry about this. 30 00:02:16,030 --> 00:02:21,020 We're going to cover it in future in our current year. 31 00:02:23,020 --> 00:02:24,470 That would be equal. 32 00:02:24,490 --> 00:02:26,920 They don't get full year. 33 00:02:28,630 --> 00:02:38,800 So if I do a lot now, current year you chewed, um, but now you need to be careful because these Geass 34 00:02:38,800 --> 00:02:41,340 increase hooked up with index that. 35 00:02:41,410 --> 00:02:46,600 So even even if I do index that e-mail, I would actually see the same page. 36 00:02:46,810 --> 00:02:52,960 But now in order to see the operators, I need to go slash operators. 37 00:02:52,970 --> 00:02:54,670 Not very good now. 38 00:02:54,670 --> 00:02:58,300 So JavaScript fundamentals and here it is the year is there 2020. 39 00:02:58,690 --> 00:03:01,330 Now, why I did this because I'm going to do something 40 00:03:04,210 --> 00:03:08,850 like maybe I'm going to do subtraction, division and stuff like that. 41 00:03:08,860 --> 00:03:19,030 So what I'm going to do here after this, I'm going to say create a variable and I will say result. 42 00:03:21,690 --> 00:03:29,940 Next year, oh, so I have coming here, I will resolve next year and into future. 43 00:03:33,540 --> 00:03:37,840 Just these are just variables, guys, don't worry about it, it's nothing, not nothing connected with 44 00:03:37,840 --> 00:03:40,510 JavaScript the way it's named right now. 45 00:03:41,020 --> 00:03:44,500 So actually, I'm going to put this one. 46 00:03:44,500 --> 00:03:45,720 Here comes a lot. 47 00:03:45,780 --> 00:03:46,700 And what else? 48 00:03:46,990 --> 00:03:54,640 So here for the result, I want to see even I want to create this date of birth. 49 00:03:54,770 --> 00:04:01,540 Delpy So my date of birth, it will be for example or it's going to be yours so will be it will for 50 00:04:01,540 --> 00:04:05,530 example nineteen ninety five. 51 00:04:05,980 --> 00:04:07,900 That's not the year that I'm born by the way. 52 00:04:08,140 --> 00:04:14,620 So what we can do is math operator minus. 53 00:04:15,070 --> 00:04:17,970 So what we can do here is I'm going to see a result. 54 00:04:19,120 --> 00:04:24,050 It will be current year minus the date of birth. 55 00:04:24,490 --> 00:04:27,830 So I'm doing this coming year is always going to be greater than date of birth. 56 00:04:27,870 --> 00:04:33,160 So I don't want to put them date of birth minus current year because I'm going to have minus value and 57 00:04:33,160 --> 00:04:34,980 I don't want to have that one right. 58 00:04:34,990 --> 00:04:37,580 Because it's not the logic for us. 59 00:04:39,040 --> 00:04:42,910 So 1995 minus twenty twenty. 60 00:04:43,240 --> 00:04:45,750 How much it will be twenty five years. 61 00:04:46,060 --> 00:04:46,440 Nice. 62 00:04:46,600 --> 00:04:51,940 So if we change this one to nineteen eighty seven the year that I'm born it's going to be thirty three 63 00:04:51,940 --> 00:04:52,300 years. 64 00:04:52,390 --> 00:04:53,930 God I'm old, I'm old. 65 00:04:54,280 --> 00:05:00,900 So that will be minus operator and we can just leave this one here like that. 66 00:05:01,570 --> 00:05:03,970 I'm just going to copy it and I'm going to put it here. 67 00:05:03,970 --> 00:05:08,530 It's going to be C plus operator in here. 68 00:05:08,530 --> 00:05:15,490 I'm going to say next year I'm going to see one right. 69 00:05:15,610 --> 00:05:21,010 Next year will be current year plus next year. 70 00:05:21,160 --> 00:05:22,570 Or you can just put one here. 71 00:05:22,830 --> 00:05:24,390 Ian, I just want to print the result. 72 00:05:24,580 --> 00:05:27,150 So this is the mutation, remember? 73 00:05:27,160 --> 00:05:34,090 So we just used the same variable here, but we placing a different result, different calculation. 74 00:05:34,420 --> 00:05:37,720 So let's see, 2021 perfect. 75 00:05:38,410 --> 00:05:46,780 You can even see like this next year it will be eight plus. 76 00:05:48,910 --> 00:05:50,700 Next year it will be twenty, twenty one. 77 00:05:51,070 --> 00:05:56,440 OK, and here I am sorry. 78 00:05:57,220 --> 00:06:04,960 So when you want to put quotations like this, I'm just going to say so double quotes and you can say 79 00:06:04,960 --> 00:06:07,840 I am. 80 00:06:12,780 --> 00:06:16,170 I'm thirty three because you don't want to use two single quotes. 81 00:06:16,290 --> 00:06:20,310 You need to put double quotes inside this here. 82 00:06:20,460 --> 00:06:21,870 So I'm thirty three. 83 00:06:21,990 --> 00:06:22,800 Very good. 84 00:06:23,220 --> 00:06:32,670 Current year this year is sorry, semicolon. 85 00:06:33,110 --> 00:06:34,470 And I'm going to say a plus here. 86 00:06:36,040 --> 00:06:36,690 Leave it a little bit. 87 00:06:36,690 --> 00:06:39,480 Space this year is twenty twenty. 88 00:06:39,720 --> 00:06:40,680 How cool is this. 89 00:06:40,680 --> 00:06:42,060 Should we have done math. 90 00:06:42,060 --> 00:06:45,080 Plus minus plus minus plus. 91 00:06:45,090 --> 00:06:45,420 Right. 92 00:06:46,230 --> 00:07:01,830 Yeah we're going to do times and let's say let's create here like variable three PWCS three and say 93 00:07:01,830 --> 00:07:05,670 here a three is going to be actually three. 94 00:07:05,880 --> 00:07:07,920 In result will be courrier times. 95 00:07:11,840 --> 00:07:12,350 Three. 96 00:07:14,760 --> 00:07:16,500 So here it will be multiplication. 97 00:07:20,300 --> 00:07:27,390 Multiplication is I should give me something like really bigger numbers, 60, 60, right. 98 00:07:27,470 --> 00:07:29,510 So you don't have to use Kering. 99 00:07:29,510 --> 00:07:35,960 You know, if this is not working for some for some reason in future, you can just hardcoded were current 100 00:07:35,960 --> 00:07:38,720 here and put it twenty. 101 00:07:38,720 --> 00:07:41,690 Twenty or your current year, 2021. 102 00:07:41,690 --> 00:07:42,860 2022 doesn't matter. 103 00:07:42,860 --> 00:07:43,570 When are you going to see it. 104 00:07:43,740 --> 00:07:46,040 I'm just going to in because we don't need to use it. 105 00:07:46,040 --> 00:07:46,310 Right. 106 00:07:46,520 --> 00:07:48,310 Because we use this date function. 107 00:07:49,070 --> 00:07:49,730 Very good. 108 00:07:49,910 --> 00:07:51,310 So now you know how to. 109 00:07:51,330 --> 00:07:56,960 OK, we need to do a division as well now. 110 00:08:01,320 --> 00:08:10,230 Division and yeah, we're going to divide it by three and let's say the result is going to be six, 111 00:08:10,230 --> 00:08:12,920 seven, three, that so he's going to be decimal number. 112 00:08:13,320 --> 00:08:14,480 How cool is that? 113 00:08:14,790 --> 00:08:16,920 This is actually very good. 114 00:08:16,920 --> 00:08:17,900 And it's working. 115 00:08:18,100 --> 00:08:26,280 No, we know how to use all of these operators, but how about logical operators? 116 00:08:26,340 --> 00:08:28,890 OK, now the next part is. 117 00:08:32,640 --> 00:08:48,900 Logical operators so they can be greater or smaller then, but now we're going to have, um, were first. 118 00:08:51,500 --> 00:09:00,420 And I'm going to have second in, first I will put for the first, I will put like 10 years. 119 00:09:00,440 --> 00:09:07,280 Second, I will just initialize it to back to what the let's say 15. 120 00:09:07,400 --> 00:09:08,720 Oh, no, let's say five. 121 00:09:09,320 --> 00:09:12,320 Know what we can do. 122 00:09:12,900 --> 00:09:14,180 We can just check. 123 00:09:16,100 --> 00:09:19,730 We can just check if the first number is greater than the second number. 124 00:09:19,730 --> 00:09:29,390 So I'm going to create an additional variable here called is bigger is smaller now they are not initialized. 125 00:09:29,390 --> 00:09:36,650 So is bigger equal first greater than the second. 126 00:09:38,540 --> 00:09:48,350 Now if I do cancel log, I'm just going to copy this one because council is bigger, because I want 127 00:09:48,350 --> 00:09:50,420 to know what, what, what value I'm printing. 128 00:09:50,960 --> 00:09:52,160 It's not going to be a result. 129 00:09:52,160 --> 00:09:52,840 I'm just going to print. 130 00:09:52,850 --> 00:09:54,170 This is bigger now. 131 00:09:54,170 --> 00:09:56,840 What, you think ten is bigger than five. 132 00:09:56,840 --> 00:09:59,140 What you think is going to be true. 133 00:09:59,420 --> 00:10:06,890 So the logical operator will always return true or false so they can return a number because we are 134 00:10:06,890 --> 00:10:09,110 comparing ten is bigger than five. 135 00:10:09,350 --> 00:10:14,470 OK, now I'm just going to put an additional line here and say is smaller. 136 00:10:17,090 --> 00:10:26,390 So first is it um, let's say is first smaller. 137 00:10:26,420 --> 00:10:29,710 The the second one what you think what will happen. 138 00:10:29,990 --> 00:10:34,520 So if Wheelock is smaller and we need to put it here is smaller size. 139 00:10:34,520 --> 00:10:35,670 Just copy control. 140 00:10:35,690 --> 00:10:36,970 See, don't worry about it. 141 00:10:37,220 --> 00:10:43,750 Now that will return false because actually ten is bigger than the second one. 142 00:10:44,210 --> 00:10:49,110 So that is how you can use logical operators. 143 00:10:49,250 --> 00:10:50,300 Now, one more thing. 144 00:10:50,720 --> 00:10:58,010 What we can do is we can just because I want to finish this with operators saying after that we're going 145 00:10:58,010 --> 00:11:03,290 to deal with something else, we can just check the type of operators. 146 00:11:05,540 --> 00:11:06,710 So what is this? 147 00:11:07,250 --> 00:11:15,780 We can just check, for example, I'm just going to copy Consul Log and I'm going to check. 148 00:11:16,550 --> 00:11:20,260 So in order to check that off, you need to actually type off. 149 00:11:20,540 --> 00:11:22,480 So that will check. 150 00:11:22,700 --> 00:11:25,340 Look what will happen type of Ismailis. 151 00:11:25,340 --> 00:11:27,050 So we're checking this variable here. 152 00:11:27,440 --> 00:11:32,480 Now, this here, it will give me a boolean value because that is what it is. 153 00:11:32,480 --> 00:11:34,100 Actually, it's true or false. 154 00:11:34,100 --> 00:11:35,270 It's Boolean values. 155 00:11:35,480 --> 00:11:36,050 Very good. 156 00:11:36,230 --> 00:11:40,100 Now, if I go back here, if I go here and if I check first. 157 00:11:41,870 --> 00:11:50,180 If I check what else we do have, OK, I'm going to create another here string, I'm just going to name 158 00:11:50,180 --> 00:11:58,260 a string or name just to put a name here, and I'm going to say name Rick and let's put it out. 159 00:11:58,280 --> 00:12:00,370 So we have first I have name. 160 00:12:01,160 --> 00:12:08,470 So for the first I should expect integer for the second type of I should expect to be string in for 161 00:12:08,480 --> 00:12:10,370 this one is we already checked. 162 00:12:10,370 --> 00:12:11,270 That is Boolean. 163 00:12:11,480 --> 00:12:17,530 So no, as I told you, integer or no string and boolean. 164 00:12:17,600 --> 00:12:23,310 Now you know also how you can check the types of operators. 165 00:12:23,570 --> 00:12:32,540 So before we are doing something else, for example, see this was something that I have done when I 166 00:12:32,540 --> 00:12:38,540 was like when I was starting like 15, 20 years ago, when I was starting with Web development in in 167 00:12:38,540 --> 00:12:40,040 actually in school. 168 00:12:40,280 --> 00:12:40,790 Right. 169 00:12:40,820 --> 00:12:41,890 In high school. 170 00:12:42,290 --> 00:12:49,400 So we had a we have a subject called programming or web development in there is something like here. 171 00:12:49,580 --> 00:12:59,750 So we can create a variable called a first number and we can have a second number. 172 00:13:02,930 --> 00:13:11,120 But at that time was super interesting because we wanted to ask the user to be prompt in into enter 173 00:13:11,120 --> 00:13:11,960 the values. 174 00:13:12,110 --> 00:13:14,680 So how we can do this. 175 00:13:14,990 --> 00:13:17,420 So do you know how we can do this now? 176 00:13:17,420 --> 00:13:23,810 This is very interesting that because we can prompt the user, for example, where I don't need actually 177 00:13:23,810 --> 00:13:28,040 so first number is equal to prompt. 178 00:13:30,830 --> 00:13:43,700 OK, and here I will ask I will ask the user, enter the first number and let's see what's happened. 179 00:13:44,030 --> 00:13:49,760 So this prompt will actually give me something like this so I can cancel it, by the way. 180 00:13:50,090 --> 00:13:57,830 But what if give me an option to enter five and if I hit enter that number five will be stored in this 181 00:13:57,830 --> 00:13:58,730 variable here. 182 00:13:58,910 --> 00:14:02,690 You're not going to be able to see it because I'm not printing anywhere. 183 00:14:02,900 --> 00:14:12,120 So here I'm going to say second number, enter the second number in the console. 184 00:14:12,140 --> 00:14:17,270 OK, so what are we going to do is actually I'm just going to put a result here. 185 00:14:18,440 --> 00:14:23,300 I'm going to use the same one result equal first number plus second. 186 00:14:23,300 --> 00:14:25,910 No, very good end result. 187 00:14:25,910 --> 00:14:27,160 I'm just going to lock the result. 188 00:14:27,500 --> 00:14:31,370 So what I'm going to do, I'm going to say twenty plus ten. 189 00:14:32,090 --> 00:14:36,680 The first number will be twenty and the second number will be ten. 190 00:14:36,980 --> 00:14:42,890 You know, one here to have the result is a thirty 2010. 191 00:14:42,890 --> 00:14:46,370 OK, we're not just doing that one. 192 00:14:46,550 --> 00:14:47,300 OK, just. 193 00:14:49,410 --> 00:14:56,220 Now, what is happening is that we are just grabbing and JavaScript is thinking that we do have only 194 00:14:57,180 --> 00:15:01,140 two Selex or 20 in 10, it considered them. 195 00:15:01,140 --> 00:15:06,150 And that's why you me in 2010, because we just concatenate them and consider them as a string. 196 00:15:06,180 --> 00:15:08,100 So maybe that was not a good example. 197 00:15:08,260 --> 00:15:10,420 Maybe should enter the first name or the second name. 198 00:15:10,710 --> 00:15:18,900 Now we are getting a lot of a if we want to do if we want to actually grab the real value, we can do 199 00:15:18,900 --> 00:15:20,160 pass Barzman. 200 00:15:20,400 --> 00:15:28,410 So because remember, they can be floats that can be integer and we can pass them the string as and 201 00:15:28,410 --> 00:15:32,960 convert it into a float or integer. 202 00:15:33,120 --> 00:15:34,260 So I'm going to say pass. 203 00:15:34,590 --> 00:15:35,070 Float. 204 00:15:36,600 --> 00:15:40,110 And there's a function, so I'm just. 205 00:15:42,160 --> 00:15:46,070 I mean, I'm going ahead fast float again. 206 00:15:46,330 --> 00:15:47,110 That's not good. 207 00:15:47,320 --> 00:15:56,370 Maybe I should stick it to the and I think with capital F should be right, not with this one float. 208 00:15:56,380 --> 00:16:04,470 Now, I expect them this string of 20 to be considered as a number and the result will be 30. 209 00:16:04,780 --> 00:16:07,490 So first float will pass in. 210 00:16:08,560 --> 00:16:11,890 But you should not be worried about this party at this stage. 211 00:16:12,170 --> 00:16:15,010 But this is not in this stage. 212 00:16:15,160 --> 00:16:18,370 So I'm going to get 35 plus 15. 213 00:16:18,380 --> 00:16:19,420 That should give me 50. 214 00:16:19,420 --> 00:16:19,730 Right. 215 00:16:19,780 --> 00:16:20,270 That's it. 216 00:16:20,560 --> 00:16:24,790 Now, I'm just going to comment this one and I'm just going to copy it. 217 00:16:25,750 --> 00:16:27,490 And actually, I'm going to copy that. 218 00:16:27,740 --> 00:16:29,150 I'm going to come this one as well. 219 00:16:29,920 --> 00:16:30,630 You know why? 220 00:16:30,640 --> 00:16:34,600 Because we're going to changes because at this stage, we should not do. 221 00:16:34,600 --> 00:16:36,400 This is the first. 222 00:16:37,240 --> 00:16:39,850 Just going to copy this first name. 223 00:16:42,100 --> 00:16:47,590 It's better like this first name and last name, now 224 00:16:50,050 --> 00:17:03,570 first name, enter your name, your name, and the second the last name will be here. 225 00:17:04,030 --> 00:17:08,070 And let's put it like this last name. 226 00:17:08,080 --> 00:17:09,190 Enter your last name. 227 00:17:13,990 --> 00:17:19,480 Now, the concatenation or the result will just work fine when we put. 228 00:17:19,480 --> 00:17:22,180 Because these are considered as what? 229 00:17:22,270 --> 00:17:22,900 As the strings. 230 00:17:23,200 --> 00:17:24,910 So sorry about this one. 231 00:17:25,060 --> 00:17:28,170 So we just went in like ahead of time. 232 00:17:28,390 --> 00:17:35,470 So enter your first name and OK, the second name will be Cyclosporine and Hideaki. 233 00:17:35,470 --> 00:17:41,500 So I don't have a space here, which we should have because it looks bizarre. 234 00:17:42,520 --> 00:17:43,570 Just going to copy it again. 235 00:17:43,780 --> 00:17:44,370 So I'm going to say. 236 00:17:44,390 --> 00:17:44,920 Rick. 237 00:17:46,290 --> 00:17:46,700 Rick. 238 00:17:46,960 --> 00:17:47,560 Yeah. 239 00:17:51,580 --> 00:17:56,590 And I'm going to hear OK, now I do have this space, OK, this lecture is going crazy. 240 00:17:56,800 --> 00:18:02,200 So we learn about operators like a logical operators these days ahead of time. 241 00:18:02,200 --> 00:18:05,590 If you don't if it's not working for some reason for you, just use this one. 242 00:18:05,860 --> 00:18:10,690 So plus division multiplication minus everything is working. 243 00:18:10,870 --> 00:18:15,000 It also logical approach is greater or smaller than in. 244 00:18:15,090 --> 00:18:23,950 We can check their type o it also we can prompt the user to tell us instore those those what the user 245 00:18:23,950 --> 00:18:29,740 is grabbing from here actually because here this is the input form we are grabbing here. 246 00:18:29,740 --> 00:18:34,410 We are storing in the first name after that when we doing from the last name we are storing in the last. 247 00:18:35,110 --> 00:18:35,510 Right. 248 00:18:35,550 --> 00:18:36,370 So thank you very much. 249 00:18:36,580 --> 00:18:40,150 I hope you enjoyed least like share, subscribe and enjoy.