1 00:00:01,950 --> 00:00:07,800 Welcome to another part where we are going to do, if else statement, so if else statement are one 2 00:00:07,800 --> 00:00:11,760 of the most important, blocking every programming languages, including JavaScript. 3 00:00:11,770 --> 00:00:16,380 So if condition is met, we're going to do some actions or else something else. 4 00:00:16,560 --> 00:00:19,600 That is what is if our statement. 5 00:00:19,640 --> 00:00:26,630 So what we're going to do, I'm just going to close everything here and I'm going to create here. 6 00:00:26,640 --> 00:00:27,360 I'm going to copy it. 7 00:00:27,370 --> 00:00:33,420 I'm going to say rename if else HTML and. 8 00:00:36,800 --> 00:00:45,110 Sorry about those guys, give us the means and I'm just going to copy this here and I'm going to put 9 00:00:45,110 --> 00:00:50,570 it on top and I don't need this, actually. 10 00:00:50,570 --> 00:00:52,000 Why do you copy it, if else? 11 00:00:53,570 --> 00:01:01,580 So I haven't created JavaScript file and then I'm going to create and now if else, I just know this, 12 00:01:01,580 --> 00:01:11,480 if else that Jarius, let just load it up here forward slash if else the HTML. 13 00:01:12,800 --> 00:01:13,290 Very good. 14 00:01:15,320 --> 00:01:17,220 So why is giving mekouar. 15 00:01:17,930 --> 00:01:18,710 Oh yeah. 16 00:01:18,710 --> 00:01:20,430 Because I haven't saved it now. 17 00:01:20,540 --> 00:01:20,990 That's good. 18 00:01:21,560 --> 00:01:24,920 So how are we declaring it else. 19 00:01:25,940 --> 00:01:28,270 So if else statements. 20 00:01:29,420 --> 00:01:33,360 So in order to do this we're going to create a couple of variables here. 21 00:01:33,380 --> 00:01:35,060 I'm going to say variables working. 22 00:01:35,870 --> 00:01:38,060 So is working 23 00:01:40,490 --> 00:01:48,850 position or work position in need? 24 00:01:49,940 --> 00:01:51,980 So Naem will be. 25 00:01:53,840 --> 00:02:00,960 Yeah, we can use double quotes or whatever you want, rig work position. 26 00:02:01,040 --> 00:02:08,600 Let's put it here as a web developer here is working. 27 00:02:08,810 --> 00:02:09,490 He's working. 28 00:02:09,500 --> 00:02:13,230 We're going to put it is working only like that. 29 00:02:13,500 --> 00:02:15,130 Now you can put a yes or no. 30 00:02:15,140 --> 00:02:15,850 Doesn't matter. 31 00:02:16,730 --> 00:02:24,580 So the condition if it's like this starts with if statement in these brackets. 32 00:02:24,650 --> 00:02:28,080 Now inside here, we're going to type the condition. 33 00:02:28,430 --> 00:02:39,920 Now, if it's working equal to these means, that is identical to know, for example, which is not 34 00:02:39,920 --> 00:02:47,210 the case in inside this currently break brackets, that is our block F block where we are putting we 35 00:02:47,210 --> 00:02:51,490 can put a couple of lines here or we can put the rest of the code or our logic. 36 00:02:51,740 --> 00:02:59,540 So should what I'm doing here, I'm checking if this variable then holds the string is having this no 37 00:02:59,540 --> 00:03:00,050 inside. 38 00:03:00,260 --> 00:03:02,280 But working is not equal to no. 39 00:03:02,450 --> 00:03:03,760 So it's not going to go there. 40 00:03:03,800 --> 00:03:09,920 So is I'm going to say causal log in the C rig not working. 41 00:03:10,970 --> 00:03:11,360 Right. 42 00:03:11,780 --> 00:03:17,570 And if I refresh it, if you go inspect it, in comes a lot. 43 00:03:17,580 --> 00:03:21,920 You will not be able to see anything because this condition is not met. 44 00:03:22,070 --> 00:03:26,990 That's why we have ls block in our block. 45 00:03:26,990 --> 00:03:28,370 We don't have conditions like this. 46 00:03:28,500 --> 00:03:28,880 Right. 47 00:03:29,180 --> 00:03:35,000 But what we do have here is because we do have the option to do the opposite of this one. 48 00:03:35,150 --> 00:03:40,310 So we know that it's not if it's not going to go there, this block, it's not going to be executed. 49 00:03:40,430 --> 00:03:45,980 Maybe you're going to have a couple of lines here, like five, six, seven lines that do some calculation 50 00:03:45,980 --> 00:03:46,820 or whatever it is. 51 00:03:47,210 --> 00:03:52,160 Now, we know that this is not going to if this is not going to do if this is not true, it's going 52 00:03:52,160 --> 00:03:56,900 to go in Elstein, you can say else. 53 00:03:58,160 --> 00:03:58,640 Yes. 54 00:04:00,260 --> 00:04:04,030 And you could see like this name. 55 00:04:06,310 --> 00:04:06,580 Oops. 56 00:04:07,610 --> 00:04:10,420 So what I'm doing here, I actually don't know. 57 00:04:11,270 --> 00:04:11,660 Yep. 58 00:04:11,660 --> 00:04:13,940 Supports the video because I need to turn on the light. 59 00:04:14,030 --> 00:04:24,260 So plus and we're going to do it here, we're going to say yes, Rick is working in actually here. 60 00:04:24,410 --> 00:04:25,670 You need space a little bit. 61 00:04:25,940 --> 00:04:26,330 Yes. 62 00:04:26,330 --> 00:04:37,630 Rick is actually working in space and we're going to put here in this position and you're going to put 63 00:04:37,640 --> 00:04:44,960 space here and to say work position now, because this condition is not me, it will go straight here. 64 00:04:44,990 --> 00:04:50,270 And we if you have more and more lines underneath, it will go there and it will get executed. 65 00:04:50,510 --> 00:04:58,430 So, yeah, rig is working and that is a position as a position developer. 66 00:04:58,430 --> 00:05:00,560 Now, it doesn't have to be. 67 00:05:00,560 --> 00:05:05,660 This here is working like that. 68 00:05:05,900 --> 00:05:07,660 It can be true or false. 69 00:05:08,600 --> 00:05:11,210 For example, let's put it false here. 70 00:05:11,210 --> 00:05:12,170 Oh, let's put it true. 71 00:05:12,170 --> 00:05:18,400 Now let's change a little bit now it can be a boolean values, so we just overwrite the value that it 72 00:05:18,410 --> 00:05:18,740 holds. 73 00:05:18,740 --> 00:05:19,910 So now it's boolean value. 74 00:05:19,910 --> 00:05:23,150 So I'm going to copy this part just to make it more. 75 00:05:24,230 --> 00:05:27,050 So now we're not going to check against anything. 76 00:05:27,320 --> 00:05:30,470 We're just going to pass in the variable here. 77 00:05:30,770 --> 00:05:34,160 So if this is return, true break. 78 00:05:34,640 --> 00:05:35,870 So we need to swap this. 79 00:05:35,950 --> 00:05:44,230 Actually, because our logic is different now, yes, Rick is working in the position they're in this 80 00:05:44,230 --> 00:05:46,360 one, Rick is not working right. 81 00:05:46,750 --> 00:05:51,240 So that is pretty much it now. 82 00:05:51,520 --> 00:05:57,540 Yes, Rick is working as a developer and this one is coming from number 19. 83 00:05:58,150 --> 00:05:59,650 Here it is, number 19. 84 00:05:59,720 --> 00:06:00,690 OK, let's change it. 85 00:06:02,770 --> 00:06:07,920 Um, we're going to make a two and we're going to make it one here. 86 00:06:09,490 --> 00:06:13,660 And so you will not you will be able to one, the rig is working in this position. 87 00:06:13,900 --> 00:06:14,850 The developer. 88 00:06:14,890 --> 00:06:15,550 Yes, Rick. 89 00:06:15,580 --> 00:06:16,840 Is working in this position. 90 00:06:16,840 --> 00:06:17,570 Web developer. 91 00:06:17,740 --> 00:06:24,100 OK, so if we change this to first look at how quickly this an EF five, if you press EF five, you 92 00:06:24,100 --> 00:06:24,910 don't have to refresh. 93 00:06:25,150 --> 00:06:26,410 Rick is not working, right. 94 00:06:26,890 --> 00:06:28,480 Means that I don't work anymore. 95 00:06:28,490 --> 00:06:29,570 And that's pretty much it. 96 00:06:29,830 --> 00:06:31,650 So that is how we can use. 97 00:06:31,660 --> 00:06:32,710 But this is very simple. 98 00:06:32,890 --> 00:06:34,930 We will use a lot more complex. 99 00:06:34,930 --> 00:06:38,560 But if else statement is the statement that you need to know. 100 00:06:39,400 --> 00:06:44,350 So if else else, if there is a lot of different statements that we can cover in the future. 101 00:06:44,620 --> 00:06:45,880 But this is the starting point. 102 00:06:45,880 --> 00:06:49,560 And I want you to know what if else statement means it. 103 00:06:49,610 --> 00:06:52,320 If this condition is met, this block is run. 104 00:06:52,330 --> 00:06:56,040 If not, then this this block is going to be run. 105 00:06:56,260 --> 00:06:57,330 That's pretty much it. 106 00:06:57,400 --> 00:07:04,030 Same in BHP, same in every in C++, JavaScript, Java's everywhere. 107 00:07:04,030 --> 00:07:06,090 The same logic is there. 108 00:07:06,130 --> 00:07:06,460 Right. 109 00:07:06,880 --> 00:07:07,570 Thank you very much. 110 00:07:08,060 --> 00:07:09,850 And I will see you in the next.