session3/challenge/3_hashes.rb
# Write a method that takes a string and returns a hash
# whose keys are all the downcased words in the string,
# and values are the number of times these words were seen.
#
# No punctuation will appear in the strings.
#
# Example:
# word_count "The dog and the cat" # => {"the" => 2, "dog" => 1, "and" => 1, "cat" => 1}
Write a method that takes a string and returns a hash
whose keys are all the downcased words in the string,
and values are the number of times these words were seen.

No punctuation will appear in the strings.


Write a method that takes a string and returns a hash whose keys are all the downcased words in the string and values are the number of times these words were seen . No punctuation will appear in the strings .
def word_count(string)
  hash = {}
  words = string.split.map(&:downcase)
  words.each { |w| hash[w] = words.count(w) }
  hash
end
def word_count ( string ) hash = { } words = string . split . map ( & :downcase ) words . each { | w | hash [ w ] = words . count ( w ) } hash end
Write a method that takes a string and returns a hash
whose keys are all the downcased words in the string,
and values are the number of times these words were seen.
Write a method that takes a string and returns a hash whose keys are all the downcased words in the string and values are the number of times these words were seen .
string
<not_specific>