1 00:00:09,570 --> 00:00:17,450 Everyone in this lesson, we are going to continue with the loop's subject for a while, I just want 2 00:00:17,450 --> 00:00:19,790 to show you a different kind of loop. 3 00:00:20,000 --> 00:00:25,250 It's going to be similar, but we are going to write it in a different way. 4 00:00:25,580 --> 00:00:29,530 So there's the WYO and do while loops. 5 00:00:29,900 --> 00:00:31,670 So let's see how this works. 6 00:00:31,920 --> 00:00:33,980 Let's go to Visual Studio Code. 7 00:00:35,170 --> 00:00:43,000 To our scripts that James file, so this time I'm just going to create a variable called Count. 8 00:00:45,410 --> 00:00:53,990 And I'm just going to assign zero to it, so now I'm going to start a while loop, so the while loop, 9 00:00:53,990 --> 00:01:01,250 it's not going to accept the three statements, the while loop is only going to accept the condition. 10 00:01:01,490 --> 00:01:03,560 So in this case, the condition. 11 00:01:04,630 --> 00:01:09,370 It's going to be that count is less than five. 12 00:01:10,980 --> 00:01:18,900 Then we just do pretty much the same thing, so we open and close curly braces and here let's just do 13 00:01:18,900 --> 00:01:22,440 console that log and just print. 14 00:01:23,890 --> 00:01:32,620 They count variable, so now we just need to increment this variable so again, we can do it in the 15 00:01:32,620 --> 00:01:34,210 loop declaration. 16 00:01:34,450 --> 00:01:36,820 This time we have to do it inside. 17 00:01:37,000 --> 00:01:44,650 So with the far loop, we just have a statement that's going to be executed at the end of each iteration 18 00:01:44,860 --> 00:01:46,090 with the wire loop. 19 00:01:46,300 --> 00:01:48,730 We just have to write it inside the loop. 20 00:01:49,030 --> 00:01:53,480 But what we are doing is basically the same as we are going to see. 21 00:01:53,800 --> 00:01:57,480 So I'm going to call the count variable. 22 00:01:57,490 --> 00:02:03,250 I'm just going to increment one after each iteration. 23 00:02:03,280 --> 00:02:06,790 So what we're doing here is exactly the same. 24 00:02:07,090 --> 00:02:15,490 But instead of starting the count variable here, then using the condition, then writing the line of 25 00:02:15,490 --> 00:02:23,260 code that's going to be executed at the end of each iteration is just a different way of writing it. 26 00:02:23,440 --> 00:02:26,890 So we start the variable before starting the loop. 27 00:02:27,190 --> 00:02:34,640 And any code that we want to execute at each iteration, we just have to write it inside. 28 00:02:35,020 --> 00:02:38,260 So by doing this, let's just save this. 29 00:02:39,660 --> 00:02:48,040 Refresh the page, and as you can see, we have pretty much the same result as we did with the for Loop. 30 00:02:48,660 --> 00:02:53,280 So now one more kind of loop that could be useful. 31 00:02:53,340 --> 00:02:55,500 Let me just comment all this. 32 00:02:59,010 --> 00:03:05,790 We also have a different kind of loop that it's the do while loop, so let me create a variable called 33 00:03:05,790 --> 00:03:10,380 Count and I'm just going to assign 10 to it. 34 00:03:12,070 --> 00:03:20,620 So now I'm just going to start this loop using the two key word and then opening and closing curly braces, 35 00:03:20,810 --> 00:03:24,420 so as you can see, it's a different way of writing it. 36 00:03:24,790 --> 00:03:29,590 So now it's not going to test anything at the first iteration. 37 00:03:29,830 --> 00:03:31,780 It's just going to go in. 38 00:03:32,320 --> 00:03:33,910 So this time, let's do it. 39 00:03:33,940 --> 00:03:35,470 And so the log. 40 00:03:37,760 --> 00:03:40,760 And let's bring the count variable. 41 00:03:41,950 --> 00:03:44,470 Then let's just do count. 42 00:03:45,800 --> 00:03:47,000 Plus, plus. 43 00:03:48,200 --> 00:03:52,620 So we can increment this variable and then at the end of the loop. 44 00:03:52,820 --> 00:03:54,020 So while. 45 00:03:55,480 --> 00:04:02,710 Open and close parentheses this time, we need to add the semicolon here, so now we are going to add 46 00:04:02,710 --> 00:04:09,520 the condition, which is going to be for this example, that count is less than five. 47 00:04:10,870 --> 00:04:18,940 So as you can see, since the beginning, this condition was false because the count was already said 48 00:04:18,940 --> 00:04:25,710 to 10, but let's see what happens when we save this and refresh the page. 49 00:04:25,720 --> 00:04:30,820 We can see that we just ran this loop at least once. 50 00:04:31,060 --> 00:04:33,040 So this could be useful. 51 00:04:33,050 --> 00:04:42,760 Sometimes we just run the loop the first time without testing any condition, and then we test the condition 52 00:04:42,760 --> 00:04:47,110 to see if we want to continue running this or not. 53 00:04:47,800 --> 00:04:51,520 So this was all that I wanted to talk about loops for the moment. 54 00:04:51,700 --> 00:04:58,000 In the next few lessons, we're going to dive a bit deeper into the conditioner's and then we're going 55 00:04:58,000 --> 00:05:02,010 to start using all this with our age HTML element. 56 00:05:02,380 --> 00:05:04,170 This is going to be exciting. 57 00:05:04,450 --> 00:05:06,250 So we'll see you in the next video.