Episode 17 - The Each Method

Exercises

  1. Start with the array
    cities = ["San Francisco", "New York", "Chicago", "Kigali"] 
    and using the “each” method, puts each element 1 line at a time.
  2. Start with the array
    foods = ["Pizza", "Spaghetti", "Creme brulee", "Ramen"] 
    and using the “each” method, puts each element, but add “is tasty.” to each line. The result should be:
    								Pizza is tasty.
    								Spaghetti is tasty.
    								Creme brulee is tasty.
    								Ramen is tasty.
    							
  3. Start with the array
    numbers = [1, 3, 7, 4]
    and using the “each” method, puts each number doubled. The result should be:
    								2
    								6
    								14
    								8
    							
  4. Start with the same array
    cities = ["San Francisco", "New York", "Chicago", "Kigali"] 
    and using the “each” method, puts each element 1 line at a time, but each city name spelled backwards. The result should be:
    								ocsicnarF naS
    								kroY weN
    								ogacihC
    								ilagiK