I am not sure what is wrong with my code. My code works as I intended and I think it did what the instruction asked me to do. What am I doing wrong?
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 up to 1.
my code :
puts "Input your statement human" text = gets.chomp words = text.split(" ") frequencies = Hash.new(0) words.each do |word| frequencies["word"]+= 1 end puts frequencies["word"]