Iterating Over the Array


#1

https://www.codecademy.com/courses/ruby-beginner-en-693PD/0/5?curriculum_id=5059f8619189a5000201fbcb#

It's working. Just not passing? "Oops, try again. It looks like you haven't set the frequencies hash correctly. Check the Hint if you need help!"

puts "I WANT TEXT"
text=gets.chomp
words=text.split
frequencies = Hash.new(0)
frequencies[words]+=1
puts frequencies[words]

#2

Well.. What do you mean by working? Maybe it should do something else?

It seems to me like the intention is to count how many times each word appears, is your code doing that for text that you enter? If you enter hello hello hello will it have counter hello 3 times?


#3

I'm not exactly sure, here are the instructions:
1. Use .each to iterate over the words array.
2. For each word we find, assume that the word itself is a key in frequencies and increment its value by 1.
3. 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 to1


#4

Then you would need to read the instructions! Get an idea for what is asked for. If there's some particular piece of information or part of the instructions that eludes you, then you'll have to ask about that. I also wrote out what I think the instructions are asking you to do but I can't tell if you read that or not. Read the instructions and compare your understanding of them to what I wrote.