ruby_basics/Projects/substrings.rb
# Implement a method #substrings that takes a word as the first argument and then an array of valid 
# substrings (your dictionary) as the second argument. It should return a hash listing each substring 
# (case insensitive) that was found in the original string and how many times it was found.
Implement a method #substrings that takes a word as the first argument and then an array of valid
substrings (your dictionary) as the second argument. It should return a hash listing each substring
(case insensitive) that was found in the original string and how many times it was found.
Implement a method #substrings that takes a word as the first argument and then an array of valid substrings ( your dictionary ) as the second argument . It should return a hash listing each substring ( case insensitive ) that was found in the original string and how many times it was found .
def substrings(word, array)
  substring = array.reduce(Hash.new(0)) do |result, item|
    result[item] += 1 if word.downcase[item]
    result
  end
  p substring
end
def substrings ( word , array ) substring = array . reduce ( Hash . new ( 0 ) ) do | result , item | result [ item ] += 1 if word . downcase [ item ] result end p substring end
Implement a method #substrings that takes a word as the first argument and then an array of valid
substrings (your dictionary) as the second argument.
Implement a method #substrings that takes a word as the first argument and then an array of valid substrings ( your dictionary ) as the second argument .
word
array