Hello, in this video, I am going to cover the for loop. So the for loop is pretty simple allows you to loop a certain amount of times. And you can have as much code as you want whoever code you want. So there's three main parts in the for loop. So we got, so we do fall in here, the three main parts, and they are separated by a semicolon. So the first part is any variable declaration and initialization.
So we're going to have dollar oil. And so that's created if it doesn't already exist, and we're going to assign a value of zero to it. You could have more like so if you want to. The second part is the condition. So we're gonna say, while i is less than 10, we're going to keep running it we're gonna keep running. And then the final part is basically a little piece of code that is right at the end of each pass of the loop.
This is usually two modify this variable somehow, you could do this modification within the loop. If there's some condition that hasn't been met, that's fine. But this will just always run at the end of each path. If we do you know, something like this, this just adds one to our using the increment operator. And if I was to echo out, let's echo out I and we will also put a brake line Actually, I can just put quotation marks and put dollar inside this will be a lot easier. So as you can see, we have 0123456789.
So it starts at zero because that's where the number starts. It does not print out 10 because this is less than 10. So once it hits 10, it's no longer gonna run for less than or equal to 10. As you can see, that is now up to 10. And this can start at any particular point in time. You can see right there.
So really, there's not much else to for loops that you really need to know you can put as much code as you want in here, and that is what gets run. And yeah, uh, what I want you to do as an extra task is, remember the arrays, video, we're going to combine arrays with a for loop. So basically, I'm going to be able to print out every piece of information in the array without having to manually specify its you know, index zero, then I'm printing it index one, index two, because if if, let's say the array had 100 values, that really, really tiresome to access each value and print them out. I want you to adapt a for loop for that. And if you have any questions, feel free to pop me a message. And as usual, I look forward to seeing you in the next video.