Hello, in this video we are going to cover the break statement. So this is in relation to basically any type of loop, I will be using the for loop as an example. But you can implement this in any loop. So the break statement basically just exits out of the for loop and continues with the rest of the code. But we have this right here, and we're doing 0123456789. And maybe if there's a certain condition that is met, then we can we no longer want or less than the rest of the loop to run.
So for example, if let's say we have some input from the user, maybe this is the no selection. And let's say the selection is menu and if the Select selection equals menu can add multiple conditions and dollar i is equal to five, then we basically want to exit out of here, and all you do is put a break. And that's it. So if we run this now, we get 01234. So once he hits four, he goes through here, Echo zero, then four is incremented to five, and he goes here, and selection equals menu that doesn't change. So that's always true.
But it requires this condition to be true as well. Which means if I five, which it isn't there any breaks and break just means exit out of the for loop, and they exit and then to show you that the rest of the code is still running, I'm going to say and of code right here. As you can see, that piece of code is not altered by the break statement. And that's it. That's all you You need to know regarding the break statement 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.