Are all words in text
export default function areWordsInText(wordsArr, text) {
const wordsArrL = wordsArr.map(el => el.toLowerCase())
const textL = text.toLowerCase()
return wordsArrL.every(elem => textL.includes(elem))
}
areWordsInText(['a', 'b', 'c'], 'abcd') = true areWordsInText(['a', 'b', 'q'], 'abcd') = false Is some word in text
export default function isSomeWordInText(wordsArr, text) {
const wordsArrL = wordsArr.map(el => el.toLowerCase())
const textL = text.toLowerCase()
return wordsArrL.some(elem => textL.includes(elem))
}
isSomeWordInText(['a', 'b', 'c'], 'abcd') = true isSomeWordInText(['a', 'b', 'q'], 'abcd') = true