I am trying to check if an array of substrings present in an array of strings. Tried using some() which is basically looking if any one of the substring is present. In below case it is returning true in both cases as 'Apple' is present in both strings but 'Hi' is not there. Basically, I wanted to make sure all the given substrings are present in an array of strings. Is there a better way to write it? Using every()
instead of some()
did not helped me as it looks for all the substrings in each string. If I use every()
it returning false every time.
Strings = ['Hello I am an Apple', 'An Apple a day'];
subStrings = ['Apple', 'Hi'];
for (const stng of Strings) {
subStrings.some((subString) => stng.includes(subString))
}