JavaScript has a relatively new for...of syntax to loop over a sequence without the need to keep track of the index manually. So, instead of typing out all of this:
let woods = ["oak", "pine", "maple"];
for (let i = 0; i < woods.length; i++) {
console.log(woods[i]);
}
// prints:
// oak
// pine
// maple
We can write this:
let woods = ["oak", "pine", "maple"];
for (let wood of woods) {
console.log(wood);
}
// prints:
// oak
// pine
// maple
It's a lot like Python's for...in syntax, but be careful not to confuse it with JavaScript's for...in syntax, which is used to loop over the keys of an object. This one has bitten me on many a tired coding session.
Textio still has a profanity problem... who knew people on the internet could be so crass???
Complete the getCleanMessages function. It returns a new array of messages where any messages containing the bad word are removed.
messages: an array of strings, where each string is a user message.badWord: a word that should be filtered out.Be sure to make the matching case insensitive.
The toLowerCase() function is very useful here!