Iterating over a collection of values is commonplace, yet the code to loop through and process elements has been cumbersome in the past.

Using the traditional for loop to iterate

The for loop is arguably one of the most widely used constructs in C-like languages.

Example

Here’s an example that uses the for loop to iterate over a list of names and print each element.

Get hands-on with 1200+ tech skills courses.