Mini Linter project overused words

I need help with
Mini Linter project

Here is assignment which caused a problem for me.

  1. There is an array of words called overusedWords . These are words overused in this story . You want to let the user of your program know how many times they have used these overused words. There are two ways to achieve this. Try it on your own first. If you need help, consult the hint.

There is 3 words in the overusedWords array.
Here is a part of code that I wrote and it does not count how many times the word ‘really’ was used.

 let reallycounter = 0
for (word = 0; word < storyWords.length; word++){
  if (word === 'really')
   { reallycounter = reallycounter + 1}
}
 console.log(reallycounter)

It should be logged 2 in console, but it logs 0.
I checked the correct answer, but still I do not understand why my for loop is incorrect.

You should log the value of word in that loop. It’ll show you the next steps you need to do (or at least give you the hint).

You’re very close to having it do what you need to, it’s just a subtle distinction you need to make.

As a refresher, how do for-loops work in javascript? If you’re coming from another language, it might be a bit of a surprise.

1 Like

Thank you for your answer you give me a hint.
I changed code a bit, and now it logs to console the right answer.

let reallycounter = 0
for ( let word = 0; word < storyWords.length; word++){
  if (storyWords [word] === 'really')
   { reallycounter = reallycounter + 1}
}
 console.log(reallycounter)
1 Like

Correct. That’s what I was getting at. :smiley: