Iterating over sequences using for each
names = ["Anna", "Bob", "Carl", "Danielle"] for i = 0 to names.length print "Hi " + names[i] end_for
Then, we use a
for loop, starting at
0. To find out how many times we will iterate, we ask the array how many items it currently has stored. We do that by using the
names variable, and, by using a dot, we can get what is known as a property from the array. This property is a value that stores how many items the array currently has. The way we can ask a sequence how many items it has will differ from language to language, but it will most likely be something like what we have done.