I have an array of strings that I want to filter by another array of words. The goal is to remove the entire string if it contains one word of the second argument.
Let's take this as an example :
comments = [ "Very useful tutorial, thank you so much!",
"React is not a damn framework, it's a LIBRARY"
"Why you put bloody kitten pictures in a tech tutorial is beyond me!",
"Which one is better, React or Angular?",
'There is no "better", it depends on your use case, DAMN YOU'
]
bannedWords = ['bloody', 'damn']
My code is returning the full array of comments
, I don't understand how I can filter through all the elements of the bannedWords
array.
I'm pretty sure I'm lacking of a basic thing right there but I'm stuck for a while now so... Thanks !
Here is what I coded :
return comments.filter(comment => comment.includes(bannedWords) == false)
};