Why is my pirate word filter censoring clean words?
function filterPirateChat(message) {
const bannedWords = ["scurvy", "booty", "plank"];
// build regex from banned list
const pattern = new RegExp(bannedWords.join("|"), "i");
return pattern.test(message);
}
console.log(filterPirateChat("an explanation is required")); // returns true!
Reply with what is broken and how you would fix it.