I wrote this code and needed help debugging.

sst00, the IDE copy for forum "feature" is no good. Maybe long ago it was but not in years has it worked right.

Code needs to be put in "code tags". They're like quote tags but they say code instead of quote.
In the forum edit window, the # button (above the smileys) makes a set of code tags. They work right.

You need to learn about arrays and loops. You should understand why once you do and look at your code again.

Your IDE has this example. Load it using the File menu.
File->Examples->05.Control->Arrays
You might not have to wire it and run it to figure it out, it's pretty simple.