For sake of an example, I have the following string:
"Federal INSURANCE Mortgage"
I want to check if any word in this string is present in the following array:
BAD_WORDS = %w{LLC CORPORATION INSURANCE COMPANY GEICO}
In our example, INSURANCE is present. So it should return true. This is what I have done:
BAD_WORDS = %w{LLC CORPORATION INSURANCE COMPANY GEICO}
BAD_WORDS.detect {|word| "Federal INSURANCE Mortgage".index(word) }.present?
=> true
BAD_WORDS.detect {|word| "Federal Mortgage".index(word) }.present?
=> false
Is this the most proficient way to solve this problem in Ruby?