Https://www.codecademy.com/paths/web-development/tracks/web-dev-js-arrays-loops-objects/modules/learn-javascript-iterators/projects/mini-linter

link: https://www.codecademy.com/paths/web-development/tracks/web-dev-js-arrays-loops-objects/modules/learn-javascript-iterators/projects/mini-linter

I am trying hard to use iterators right, but It’s not being easy to learn.

On item 4 of the exercicise, why does this code doesnt work?:

let repetition = storyWords.filter(function(i){
 if (i = overusedWords)
    return i
});

and this one does?

let repetition = storyWords.filter(function(i){
  if (i === 'really' || i === 'very' || i === 'basically')
  return i
});

Thanks in advance

Hello @jhonathanc. Have you defined overusedWords? Also, you should look at the comparison operator ===. Is it the same as the = used here?

I hope this helps!

Yes, it was set by codecademy at the beggining of the quiz.

I tried with = and === with no success

Hello @jhonathanc,

overusedWords is an array so you can’t compare it with i (a string). You could use the Array.prototype.includes method and try something like

let repetition = storyWords.filter(function(i){
  if (overusedWords.includes(i)) {
  return i
});

Let me know if this helps!

2 Likes

Thank you, @nicolevatland and @codeneutrino

2 Likes