I want to check if any elements in this array words = ["foo", "bar", "spooky", "rick james"]
are substrings of the phrase sentence = "something spooky this way comes"
.
Return true if there is any match, false if not.
My current solution (works but probably inefficient, I'm still learning Ruby):
is_there_a_substring = false
words.each do |word|
if sentence.includes?(word)
is_there_a_substring = true
break
end
end
return is_there_a_substring