JS Syntax II Iterator project <Mini Linter>

Hi y’all!
I have some questions :smiley:

So, this is what I did to find out the counts for overusedWords:

const overuseReally = storyWords.filter(word => word === overusedWords[0]).length;
const overuseVery = storyWords.filter(word => word === overusedWords[1]).length;
const overuseBasically = storyWords.filter(word => word === overusedWords[2]).length;

console.log(`Count 'really': ${overuseReally}, Count 'very': ${overuseVery}, Count 'basically': ${overuseBasically}`);

And I wanted to use the same method for getting number of sentences, but I realized that “.” should be a single string for me to be able to do so. So I used this method instead:

let countSentences = 0;

for (word of storyWords) {
  if (word[word.length - 1] === "." || word[word.length - 1] === "!") {
    countSentences += 1;
  }
};
console.log(`Count sentences: ${countSentences}`);
  • I’m really curious, how do you separate words from “.” / “!” ?
    Ex) from “life.” to “life”, “.”

  • Also, I’d love to solve Task no. 8 :

  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.
    If anyone was able to do those please let me know!

Hey, @mega5149737189. To address the first doubt you have about “./!”. You don’t actually need to separate these from a string to compare. There are various string functions that’d help you achieve the same! For example, when I was solving this challenge, I used the .includes() method of strings to find the dot and the exclamation mark present in a string.

You can refer to the documentation with this link.

I’ve been able to work my way through task 8. So, I should be able to help out. What do you think you could do to address each of these tasks separately?

1 Like