Perfect! Next up: we want to iterate over words to add each word to our frequencies hash, one at a time.

colors = { "red" => 2, "blue" => 3 } colors["blue"] += 1 puts colors["blue"]
  1. In the above example, we first create a hash mapping strings to integers.
  2. Then, we increment the value stored by "blue" by 1.
  3. Finally, we print out 4, the value stored by "blue".



Use .each to iterate over the words array.

For each word we find, assume that the word itself is a key in frequencies and increment its value by 1.

This is why our default is 0. The first time we find the word, it will have a default value of 0 that we can increment by 1.

Take a look at the Hint if you need help.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?