

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 8
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
Checking whether a value exists in an array is really easy in JavaScript, just use the .includes() method.
fruits = ["apple", "orange", "banana"];
console.log(fruits.includes("orange"));
// Prints: true
console.log(fruits.includes("pear"));
// Prints: false
Array .includes() checks exact elements; string .includes() checks substrings:
const str = "Hello, world!";
console.log(str.includes("world"));
// Prints: true
console.log(str.includes("banana"));
// Prints: false
Let's update Textio's profanity detection to make it a little more robust. Rather than just marking a review as "clean" or "not clean" we need to give it a ranking, which we'll represent as one of 3 strings:
clean: No bad wordsdirty: 1 bad wordfilthy: 2 or more different bad wordsThe bad words are:
Complete the getCleanRank function. It takes an array of words, reviewWords. Check if reviewWords includes the bad words, then return the appropriate ranking. If a word contains special characters (like "d@ng"), it should fool our naive algorithm for now.