Welcome back! Today I moved to the next step of programming; Arrays and Loops! I remember for loops and while loops from high school, but I actually learned some new ones during this tutorial!

Now this may look similar to the previous one, however, it’s actually a bit more complex! For starters, I moved the script from the text box, over to the background, and make the textboxes into children in the hierarchy to that same background. Next, I created a for loop, making sure to update the text on every textbox, not just the first one.

After having all textboxes show the updated number, I then went to write every version of this loop, so see the major differences between them. Below, you can see the different variants. The while loops created the variable outside, then updates the variable inside, as opposed to being inside the single line in the for loop. The do while loop is an interesting one, but has it’s faults. If the value is zero on the first update, then it will be skipped, due to the check happening at the end of the loop. The final two, foreach and for, are simply another way to go about the process all together. The foreach loop actively decides how many textboxes are in the array of textboxes and does them all at once, as opposed to the rest, which loops based on the count. The final for loop shows a rephrasing of the code, where it looks at the array within the loop itself, as opposed to looking at the loop outside of the loop.
