Histogram lesson 5


#1

puts "What do you want to graph?"
text=gets.chomp
words = text.split
frequencies = Hash.new (0)
words.each = { |element| frequencies[element] += 1}

whats wrong with the code


#2

@rptaco02 - I have the same issue. I entered the below and it keeps on saying frequencies is not a hash

puts "Text please: "
text = gets.chomp
words = text.split(" ")
frequencies = Hash.new(0)


#3

@rptaco02 @daneezo This worked for me:

words.each {|word|
puts frequencies[word] += 1
}