In this lesson, we will begin the study of loops. Loops are used to execute a piece of code multiple times in a row.
Why do we need them - imagine that you need
100 array elements. If you
access each element separately by its key,
it will take
100 lines of code, and
in order to write this code, you will need
to spend quite a lot of time.
Loops can repeat some code a given number of times. Each such step of the loop is called a loop iteration.
Loops often use special variables that
increment their value by one each iteration.
Such variables are called loop counters.
Counters are used to count how many times
a loop has been executed. It is customary
to use the letters
k for counters.