I have the following code. A body object and a sensitive word array.
If the body key contains any word from sensitive words, it should returns true.
const body = {
name: "",
email: "",
otpp: ""
}
const sensitiveWords = ["password", "pin", "otp"]
const isSensitive = sensitiveWords.some(el => Object.keys(body).map(name => name.toLowerCase()).includes(el)) || false
console.log(isSensitive);
// returns: false
// expected result: true
But as you can see, the word otp is in the sensitive words, but its not matching otpp. I guess its because its looking for full string match.
I need the above function to return true since the key contains otp in otpp.
Thank you.