Https://www.codecademy.com/paths/build-web-apps-with-react/tracks/bwa-javascript-iterators-objects-and-classes/modules/learn-javascript-iterators/projects/mini-linter

Please can someone help me?

In Mini Linter Project, step 3 requires you to use .filter to remove words that are also in the unnecessaryWords array. I have managed to do this using .includes (CODE 1):

let betterWords = storyWords.filter(betterWord =>
unnecessaryWords.includes(betterWord)
);

I’ve also managed to do this using the && operators (CODE 2), but this isn’t particularly versatile.

let betterWords = storyWords.filter(betterWord => {
return betterWord !== ‘extremely’ && betterWord !== ‘literally’ && betterWord !== ‘actually’;
}
);

I’d also like to know how this can be done using a loop, which I have attempted (CODE 3), but this does not produce the required result.

let betterWords = storyWords.filter(betterWord => {
for (i=0; i < unnecessaryWords.length; i++){
return betterWord === unnecessaryWords[i];
};
});
console.log(betterWords);//<-output “[ ‘extremely’, ‘extremely’ ]”