We introduced the break statement. When we talked about the switch conditional. Well, the break statement can also play a role in loops. Whenever a loop encounters a break statement, it will exit immediately out of the loop despite what the conditional may say. It is a way to exit out of a loop if something happens, it would be a way to allow you to to check different conditionals inside the loop. All right, let's jump to the example we just did.
We had a for loop here that we're printing it was printing out multiples of six between one and 100. Just to show you how break would work Saturday if statement here if i is greater than 50 Break, there's our break statement. Let's see what would happen now that should exit out of the loop as soon as we pass 50 pull up the console. Sure enough, we get to 48 and then it breaks out of the loop. So the break statement can be used inside a loop to check some other conditional and then break out of the loop and continue on with the rest of the code. So just to show you that it continues the program continues.
And this is outside the loop so this would not this will not execute until it breaks out of the loop and is 51 by the time it breaks out of the loop. So at times you might find a need to use the break stay Let's continue to the next topic.