I would like to take an array...
teams = ["Cowboys", "Heat", "Blue Devils"]
...and convert this to a string...
# => "1. Cowboys 2. Heat 3. Blue Devils"
...and use string interpolation to concatenate it with another string.
# => "My three favorite teams: 1. Cowboys 2. Heat 3. Blue Devils"
Use
each_with_index
:Then you can interpolate:
each_with_index
adds the position of each element and returns an enumerator that you can map over with a block. The block receives each item and its index.