Cannot get past Iterating Over an Array


#1


I keep getting the message "it looks like you haven't added any key-value pairs to the frequencies hash."

I have been cruising along pretty well so far until this exercise and I CANNOT get past it. I've tried restructuing the code to mirror some of the others in the Q&A section just to see if it would allow for me to get past even though they looked exactly like my code, but am still getting the same message. Can anybody point out what it is I am failing to do as it seems that I have the right code in place relative to what everybody else is suggesting.... Help much appreciated

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


puts "text here"
text = gets.chomp
words = text.split (" ")
frequencies = Hash.new(0)
words.each { |word| frequencies[word] += 1 }


#2

I just tried your code and it passed as expected. There are no errors.


#3

Haha thanks. I don't know what the deal is, I feel like I am taking crazy pills. I've been stuck in this spot for an entire day and it still won't let me get past this exercise using the exact code I pasted in my initial post. Getting pretty frustrated...


#4

Sounds rather odd. Have you tried,

page refresh

another browser

?


#5

Yeah, I've tried both. At a bit of a loss at the moment. Thanks for taking the time to respond though, I really appreciate it.


#6

There is nothing wrong with the above, but have you tried with no space after split? That is really just tossing something out there as this has me surprised. We've never seen this before.


#7

Do you enter any string when "text here" shows in console?


#8

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