Iterating over the array exercise 5


I can't figure this out! I tired the forum to find some answers first however still not sure what I am doing wrong.

here is the code:
puts "some text here is needed"
text = gets.chomp
words = text.split(" ")
frequencies =
words.each { |word| frequencies[word] += 1 }

puts frequencies[word]

The error says:
Oops, try again. Your code doesn't look quite right. Check the Hint if you need help!

and also:
undefined local variable or method `word' for #



Please, what exercise are we looking at here? A link preferably.

By the way, word isn't defined but words is. Maybe, depending on the exercise, you should make all word to be words.


sorry yes of course here is the link:


So, the error is in this.

You wrote code to help split a text into words and then find how frequently it occurs. So, you should be finding the frequency of words and not word on the last line I pointed at, above.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.