Episode 19 - Hashes

Exercises

  1. Start with the hash
    pet_ages = {"Spot" => 3, "Snowy" => 2, "Salem" => 4}
    Use the "each" method to print out each pet name and age in a sentence. The output should be:
    Spot is 3 years old.
    Snowy is 2 years old.
    Salem is 4 years old. 
  2. Write a program that serves as a dictionary. To keep it simple, the dictionary will only contain five words and their definitions. When the user starts the program, the program lists all five words that the user can look up. The user can then enter a word, and the program will return its definition.