https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-javascript-syntax-part-ii/modules/fecp-learn-javascript-syntax-iterators/projects/mini-linter [you do not need this]
My Mini Linter is done and runs fine. Unlike the solution, my program was not dependent on on the content of overusedWords. I found code similar to my needs in getting counts of overusedWords and adapted it. If only I clearly understood it. This code works.
Note the ternary operator. The condition part is not a logical statement but an assignment statement. That is confusing. What I understand of this, is that when a new word is found, the word is added to the counts object as a property with the value of 1. When a previous word is encountered, the value is incremented by 1. Thus we have a result like this: counts = { really: 2, basically: 1, very: 5 } . I can not explain the mechanics of the code.
//foundOverusedWords is the result of iterating over betterWords and finding the indexes where overused words occur
//then using those indexes to build foundOverusedWords
foundOverusedWords = ['really', 'basically', 'really', 'very', 'very', 'very', 'very', 'very'];
const counts = {};
for (const word of foundOverusedWords) {
counts[word] = counts[word] ? counts[word] + 1 : 1;
}
//output counts = { really: 2, basically: 1, very: 5 } this is correct
console.log(counts);