I am comparing two arrays for matched items but I need to make them case insensitive.
here is the code: credit for this code to @PatrickRoberts here
const words = ['word1', 'word2', 'word3']
const texts = [
{name: 'blah', description: 'word4'},
{name: 'blah2', description: 'word1'},
{name: 'blah3', description: 'word5'}
]
console.log(
texts.some(
({ description }) => words.includes(description)
)
)
I was able to get the second part to lower case by doing words.includes(description.toLowerCase())
but I don't know how to handle the first part: texts.some(({ description })
I should mention I have tried adding toLowerCase() to { description } like this: { description.toLowerCase() }
but this does not work
any help is greatly appreciated