Say I have a string as:
const subject = "This process is flawless"
and I have an array as:
const matchArray = ["process","procedure","job"]
I want it such that if subject contains any keyword from matchArray,
if (subject matches any keyword of matchArray ){
console.log('true')
}
My first instinct was to use includes but I don't want to match array with a string but instead string with an array.
I'm still exploring, if anyone could guide me that would be reall helpful.
Edit: I found this soultion, but is there any better solution than this
const subject = "This process is flawless"
const matchArray = ["process","procedure","job"]
const exists = matchArray.some(matchArray => subject.includes(matchArray))
if (exists) {
console.log("Yes");
// notify
}