Page 64 - Computer_Genius_v2.1_C7_flipbook
P. 64

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.
































                       62    Computer Genius (V2.1)-VII
   59   60   61   62   63   64   65   66   67   68   69