Mini Linter project additional ideas

Hello, everybody!

Help me out with this project, I’ve completed it with a help of the video in it, but the question is how to make the last three additional tasks? What I want ti know is how to replace overused words with something else?

"Here are some ideas:

  1. For the overused words, remove it every other time it appears.
  2. Write a function that finds the word that appears the greatest number of times.
  3. Replaced overused words with something else."

I’m sorry, I didn’t quite get what should I do. I’m just starting learning programming, so it can take time for me to understand. here is what I’ve done.

Sorry! I totally forgot this was in JS. That’s Python by the way.
Nice. So after you have your count for each word, compare them, and output the word with the greatest count.

if (reallyCount > veryCount && reallyCount > basicallyCount){
  console.log('The word that appears the greatest amount of times is really!')
}

Rinse repeat.

I found this to help with your replacing problem.

var str = "Visit Microsoft!";
var res = str.replace("Microsoft", "W3Schools");
console.log(res)//Visit W3Schools!

#To replace all occurrences of a string, you use a regular expression with the global flag (g):

let str = "Are you OK? Yes, I'm OK.";
let result = str.replace(/OK/g,'fine');

storyWords = storyWords.replace(/really/g, 'pizza')
#You want to reassign it to storyWords
#repeat for all words

#You can even use /word/gi to replace all cases. For example, the code above will only work if the word is really, but what if it is really. with a period at the end?
storyWords = storyWords.replace(/really/gi, 'pizza')
#repeat for all words

Might need to combine your StoryWords list again.

I’m sorry, I still do not understand you quite, what should do I do? Maybe you would see my code snippet? Thank you again for your help!

Well, you need the greatest count right?
Using this code:

if (reallyCount > veryCount && reallyCount > basicallyCount){
  console.log('The word that appears the greatest amount of times is really!')
}
elif (veryCount > reallyCount && veryCount > basicallyCount){
  //repeat
}

What this is doing is checking if your wordCount is greater than anotherWordCount and anotherWordCount. You would repeat this for every count.

//random example
if (5>2 && 5>3){
  console.log('5 is greater than 2 and 3!')
}

After joining together betterWords again, which I see you did, you can use the above code.

storyWords = storyWords.replace('really', 'replacementWord')
#repeat for all words