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
Strings actually have an .includes() method too!
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.