Trouble understanding one aspect of this code


#1



I'm confused about one small aspect of this exercise. What part of the code makes it so that it doesn't just add multiple instances of a particular word to the Hash?

For example, if the phrase someone inputs is "Hello hello hello" why is the final Hash [Hello, 3] and not [[Hello, 1], [Hello, 1], [Hello, 1]]?

I know this might be obvious but I can't see it...

Thanks.



#2

@kairos222,

Give us the FULL code you are using....


#3

because you're supposed to be counting how many times the word appears. if you've typed 'hello' 3 times, it tell you it appeared three times. it compiles it into one hash instead of separate ones, making it easier to see how many times it's appeared. That way you can see the count at a glance instead of having to count the hashes