Skip to content Skip to sidebar Skip to footer

If Contains Characters Then X, Else Y (puppeteer)

I have this code which should work in theory, but it doesn't. I guess there is something that it's missing: function containsWords(words, word) { return words.filter(w => w

Solution 1:

In containsWords() you compare the entire message with each word. To check if the message contains any word, you need something like this:

function containsWords(words, message) {
    return words.some(w => message.includes(w));
}

Post a Comment for "If Contains Characters Then X, Else Y (puppeteer)"