Everyone in this lesson, we are going to continue with the loop's subject for a while, I just want
to show you a different kind of loop.
It's going to be similar, but we are going to write it in a different way.
So there's the WYO and do while loops.
So let's see how this works.
Let's go to Visual Studio Code.
To our scripts that James file, so this time I'm just going to create a variable called Count.
And I'm just going to assign zero to it, so now I'm going to start a while loop, so the while loop,
it's not going to accept the three statements, the while loop is only going to accept the condition.
So in this case, the condition.
It's going to be that count is less than five.
Then we just do pretty much the same thing, so we open and close curly braces and here let's just do
console that log and just print.
They count variable, so now we just need to increment this variable so again, we can do it in the
loop declaration.
This time we have to do it inside.
So with the far loop, we just have a statement that's going to be executed at the end of each iteration
with the wire loop.
We just have to write it inside the loop.
But what we are doing is basically the same as we are going to see.
So I'm going to call the count variable.
I'm just going to increment one after each iteration.
So what we're doing here is exactly the same.
But instead of starting the count variable here, then using the condition, then writing the line of
code that's going to be executed at the end of each iteration is just a different way of writing it.
So we start the variable before starting the loop.
And any code that we want to execute at each iteration, we just have to write it inside.
So by doing this, let's just save this.
Refresh the page, and as you can see, we have pretty much the same result as we did with the for Loop.
So now one more kind of loop that could be useful.
Let me just comment all this.
We also have a different kind of loop that it's the do while loop, so let me create a variable called
Count and I'm just going to assign 10 to it.
So now I'm just going to start this loop using the two key word and then opening and closing curly braces,
so as you can see, it's a different way of writing it.
So now it's not going to test anything at the first iteration.
It's just going to go in.
So this time, let's do it.
And so the log.
And let's bring the count variable.
Then let's just do count.
Plus, plus.
So we can increment this variable and then at the end of the loop.
So while.
Open and close parentheses this time, we need to add the semicolon here, so now we are going to add
the condition, which is going to be for this example, that count is less than five.
So as you can see, since the beginning, this condition was false because the count was already said
to 10, but let's see what happens when we save this and refresh the page.
We can see that we just ran this loop at least once.
So this could be useful.
Sometimes we just run the loop the first time without testing any condition, and then we test the condition
to see if we want to continue running this or not.
So this was all that I wanted to talk about loops for the moment.
In the next few lessons, we're going to dive a bit deeper into the conditioner's and then we're going
to start using all this with our age HTML element.
This is going to be exciting.
So we'll see you in the next video.