Page 71 - Dig_CodeAI_V2.1_Class_8
P. 71
Break
The break statement changes the normal flow of execution of the statement by exiting the existing
loop and continuing the flow of statement after that loop. Using break statement, the control skips
the lines after the break statement if present and executes the first statement outside the loop.
Break statement is used to come out of a loop early when the specific condition is met. For example:
if you’re going through items and find what you’re looking for, you can use break to exit the loop
early.
Let us create a project in MakeCode Arcade that demonstrates the use of break block. Prepare the
project in MakeCode Arcade to display the numbers till 6 but as soon as it reaches 4 it exits from the
loop as shown below:
When you run the project, the following output displays the first iteration of the repeat loop.
Advanced MakeCode Arcade 69

