Hi I want to create very basic profanity filter in JavaScript.
I've an array called badWords
and also I've constant called description
. I won't to check whether there is any bad word contains in that description
.
This is what I've done upto now.
const badWords = ["Donald Trump","Mr.Burns","Sathan"];
const description = "Mr.Burns entered to the hall."
let isInclude = false;
badWords.forEach(word=>{
if(description.includes(word)){
isInclude = true
}
})
console.log(`Is include`,isInclude)
Only problem is I've to loop through badWords
array. Is there a way to get this done without looping through the array?