4. Creating the Frequencies Hash


#1

puts "Text please: "
text = gets.chomp

words = text.split(" ")
frequencies = Hash.new(0)
words.each { |word| frequencies[word] += 1 }
frequencies = frequencies.sort_by {|a, b| b }
frequencies.reverse!
frequencies.each { |word, frequency| puts word + " " + frequency.to_s }

I still get the error of "Oops, try again. It looks like frequencies isn't a hash."

I have also tried 4 browsers and they all come up as an error.

Help!?


#2

You're missing "do" in your last line:


#3

No, do/end is a block, and so is {}. This is not his issue.

@brenden_c

In the exercise 4, they're only asking you to create the hash with 0 as a default value, nothing else. Remove all the unnecessary code.