Mini Linter | # 4


#1
let storyWords = story.split(" ");
let unnecessaryWords = ['extremely', 'literally', 'actually' ];

let betterWords = storyWords.filter(function(word){
  if (!unnecessaryWords.includes(word)){
    return word;
  }
})

let totalCnt = [];
let reallyCnt = 0;
let veryCnt = 0;
let basicallyCnt = 0;


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

for(let i = 0; i < betterWords.length; i++){
  currentWord = betterWords[i];
  if(i === 'really'){
    reallyCnt += 1;
  }
  if(i === 'very'){
    veryCnt += 1;
    
  }
  if(i === 'basically'){
    basicallyCnt += 1;
  }
  totalCnt.push(currentWord);
}

console.log(totalCnt.length);

The terminal shows 179, which is the total length of the original length of variable being looped. I’ve tried different ways in figuring this out. Please let me know what I’m doing wrong. I know that from

currentWord = betterWords[i];
  if(i === 'really'){
    reallyCnt += 1;
  }
  if(i === 'very'){
    veryCnt += 1;
    
  }
  if(i === 'basically'){
    basicallyCnt += 1;
  }
  totalCnt.push(currentWord);

basically skips the if statements since currentWord isn’t being utilized until it’s pushed. There are some things I’m missing but just can’t seem to find it.

Thank you.