[Quick Coding Tips] Use Loops in VEXcode VR (Part 2) -- Nested Loop

Use Nested Loops in the VEXcode VR

Loops can be nested inside one another. This means that the inner loop is executed one time in its entirety for every time the outer loop executes. In other words, the inner loop must finish all of its iterations before the outer loop can continue to its next iteration.

Nested loops are powerful tools that leave us more room for creativity!

The following are two typical examples of using Nested Loops in VEXcode VR projects.

  1. Use a Nested Loop to create an intricate shape composed of several polygons.
    The purpose of the following project (Image 5) is to use a nested loop to draw a triangle repeatedly to make a Spirograph Art.

image

nested2

  1. Use a nested loop to navigate the robot to move in rows and columns.
    In the following project, we use a nested loop to guide the robot to fill the color in each Grid on the Number Grid Map Playground, starting from Grid 1 and progressing through Grid 90.

image

nested3

Loops are not only a foundational concept in programming but also a powerful tool in our coding arsenal. By understanding and practicing the use of loops, we will be better equipped to solve a wide range of problems in our coding journey.

Please let us know if you have any questions, comments, or feedback. Thank you!

2 Likes