Iterators - Practice

let mystory = 'This is really a test on very set up  is basically practices and literally not extremely true but actually false ';

let SPmystory = mystory.split(' ');

let overusedWords = ['really', 'very', 'basically','neo', 'literally'];

const MoreWords = SPmystory.filter(words =>{
    check (words);
})

function check (words){
  for(let i = 0; i < overusedWords.length;i++){
    if(words !== overusedWords[i]){
      //check to see  if i increments and the output 
      console.log(i);
      console.log(words);
     //should return word that is not in the overusedWords array
      return words;
    }
    else{
       return 'same';
    }
  }
}

console.log(MoreWords);

Since the ‘return’ stops the for loop from incrementing what else can i use to check each string in my array?

hey @novalight91. Thanks for sharing your code. Before we (potential helpers) can begin to help you solve this, we’ll need a bit more information, such as:

  1. A description of the issue you’re having trouble with – make sure to be specific and give context. This is good to have at the start of a new topic so that we’re introduced to the issue you’re stuck on.
  2. Include a URL/Screenshot, if applicable.

For reference, see this topic: [How-to] Create a topic that everyone will read

Ok, I’ll fix it

thank you

1 Like