Loops
When you want to repeat operations, you can use loops. Loops give you a
neat way to do something a set number of times or to do operations until
a certain condition (that you define) is met. Collection types such as arrays
and dictionaries use loops for iteration.
for-condition-increment Loop
This for loop will be familiar to many programmers. The for-conditionincrement
loop gives you a loop that will execute a set number of times.
You will have to use the for keyword along with an ending condition and an
increment statement.
The loop shown in Listing 22-1 prints out 1 through 10 to the console as an
example.
Listing 22-1. for-condition-increment Loop
for var i = 1; i