Understund the filter() operator working with an array of string... STUCK

Hi everyone, I’m getting stuck on task number 3 of the miniLinter objective.
I’m trying to iterate trough an array and get save into a new array the words that are not contiain into another array… Here below i leave what is asking me to do and my code. Thanks in advance for the help.

There is an array of words that are unnecessary. Iterate over your array to filter out these words. Save the remaining words in an array called betterWords . There are several ways that you could achieve this.

let overusedWords = [‘really’, ‘very’, ‘basically’];

let unnecessaryWords = [‘extremely’, ‘literally’, ‘actually’ ];

let storyWords = story.split(’’);
let betterWords = storyWords.filter((arr) => {if(arr.includes(unnecessaryWords))
return arr} )

console.log(storyWords.length)

here below i will link to the exercise as well
https://www.codecademy.com/courses/introduction-to-javascript/projects/mini-linter

Thanks in advance for your help guys

console.log() is your friend. When you log storyWords itself what do you get? Also make sure you are using the .filter() method correctly. Here is the documentation for it.

i know i do not get anything when i type console.log

the thing is that i do not understund how to filter trough an array check if there isvalue from another array and report into another one… i’m tryng from 2 days…

You have a couple of issues. The first one will be quickly brought to light if you follow @ktsotras’s suggestion, and add a console.log(storyWords) statement to your code right after you assign the value to storyWords and before trying to use the Array.filter() method on it.

After that, you need to consider how the Array.filter() method works, but first things first. Try the above suggestion, and get storyWords in shape.

1 Like