Code Editor
Create a Histogram

Iterating Over the Array

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".
Report a Bug
If you see a bug or any other issue with this page, please report it here.