Lesson 8, page 5 of 8, What is required?

I am stuck on Lesson 8, page 5 of 8.

I do not understand what is required.

I do understand that I have to enter multiple words into a string.
Then move those words into an array.
Then count the occurrences of each word in the array.
The total number of occurrences for each word is to be written into ‘frequencies’.

Am I supposed to populate ‘frequencies’ with the words and the number of its occurrences or just the number of occurrences?

For the text “This is text this is”, should the content of ‘frequencies’ be this => 2, is => 2, text => 1,
2 , 2, 1

Here is he link

The word is added to the hash as a key when it is first encountered. That and subsequent occurrences will increment the count value for that word.

It should be the hash.

 this => 2, is => 2, text => 1
words.each do |word|
  frequencies[word] += 1
puts frequencies
Enter some text: 
the rain in Spain falls mainly in the plains
{"the"=>2, "rain"=>1, "in"=>2, "Spain"=>1, "falls"=>1, "mainly"=>1, "plains"=>1}

Thanks for that. This task is very hard. Is it possible to reset this task as not completed so that I can look at the correct answer. My solution does not code for a repeat word but it has been accepted as complete.

Can 6/8 also be reset?

I want to study the correct answer for both as I am sure I have not done this as well as I can.

Is that possible?

Wait to hear

Cancel that request I have achieved 5/8 and 6/8 appears to have reset itself

1 Like