

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 7
click for more info
Not enough gems
Cost: 6 gems
1: Arrays
incomplete
2: Array Length
incomplete
3: Array Spread
incomplete
4: Includes
incomplete
5: For...of Loops
incomplete
6: Slicing Arrays
incomplete
7: const Arrays
incomplete
8: Destructure
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
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 should return a new array containing only the "clean" messages - messages that don't contain the bad word. It accepts:
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() method is very useful here!