Mini Linter HELP


I need a little help with this project please. Link:

I’m on step 4, which requires you to iterate over the story and alert the user of how many times each overused word repeats. I have no idea how to even begin the code, I’m a little lost. I believe a for loop would be used in some fashion. Can someone just get me started with some help, I don’t want a full solution I’d like to figure it out.

  1. In the code editor, there is a string called story. We want to gather some information about the individual words and sentences in the string. Let’s split the string into individual words and save them in a new array called storyWords.

So how might we go about doing that?


Here is my current code. I’m working on getting my for loop correct so it logs each instance of the overusedWords.

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

let unnecessaryWords = ['extremely', 'literally', 'actually' ];

let storyWords = story.split(' ');

let betterWords = storyWords.filter(word => !unnecessaryWords.includes(word));

for (let i = 0; i <= betterWords.length; i++) {
  if (betterWords[i] === unnecessaryWords[0]) {
  }else if (betterWords[i] === unnecessaryWords[1]) {
  }else if (betterWords[i] === unnecessaryWords[2]){
  }else {
console.log(betterWords.join(' '));


Your code for the first three steps looks good. Step 4 would seem to be where you ran into problems. Let’s go back to the step 3 code.

let betterWords = storyWords.filter(word => ! unnecessaryWords.includes(word));
//                                          ^

In the above we filter words we do not want in the story words, and save the rest. In step 4 we want to do the opposite, save only the overused words, so intuitively, what will we write? (Hint: leave off the NOT operator when you switch variable names.)

We do need to store a list of filtered words in a variable of our own making. I used, excessWords. Now use the pattern above to complete this step.

It is a good idea to log results for each step whether in the instructions or not. It is after all a free form project, not a checked exercise. The more you see along the way, the simpler it is to complete the project.

Leave the rest of your code alone, for now and just insert the step 4 code underneath the step 3 code and get a printout of the results, both the length and the returned list. Please post your step 4 results in a reply. Thanks.


Ok I got it to work:

let overusedWordsIndex = betterWords.filter(word => overusedWords.includes(word));

  let reallyCount = 0;
  let veryCount = 0;
  let basicallyCount = 0;

for (let repetition = 0; repetition <= overusedWordsIndex.length; repetition++) {
  if (overusedWordsIndex[repetition] === overusedWords[0]) {
  }else if (overusedWordsIndex[repetition] === overusedWords[1]) {
  }else {

console.log(betterWords.join(' '));
console.log('There are ' + overusedWordsIndex.length + ' overused words: ' + overusedWordsIndex.join(' '));
console.log(`Really appears ${reallyCount} times.`);
console.log(`Very appears ${veryCount} times.`);
console.log(`Basically appears ${basicallyCount} times.`);

How would you rate this? Can I simplify it?


Well done! That tackles step 4. What outputs did you get?


We can take a look at step 5 in a moment. I’d like to see your output above.


Sorry, but I assume you mean what does the console show? How do I embed that?

The console reads:

There are 8 overused words: really basically really very very very very very
Really appears 2 times.
Very appears 5 times.
Basically appears 2 times.


Just as we expected. Very good. You put a lot of work into that report, which for inspection purposes might be considered overkill. Inspection is the programmer inspecting variables and states. For our purposes this would have sufficed…

[ 'really',
  'very' ]

Good that you are spending time writing code, though. Don’t get me wrong. Practice comes in many forms, and alot of coding is ‘on demand’ as we go. If it means a segue from the production stream, so be it. Kudos for your effort.

Now we can proceed to the next step. How would you envision we could count the sentences in the text?

Hint: What character indicates a full stop? In most languages it is the period, ., more commonly known these days as dot.

There are other sentence stoppers. Any symbols with a dot on the baseline are full stop tokens, grammatically speaking. These marks would include the following:

colon        :  such that a block quote or list would follow
question     ?  an interrogatory indicator
exclamation  !  an exclamatory indicator

Consider how all this information can be incorporated into your solution.


Thank you for the help, I will work on this and report back.


Right, so I spent a little time on this and I can’t seem to figure out a good way to get it started. Could I possibly have a hint to get me started. I understand I should iterate over the story and log every time i come to a period or exclamation point, but I’m not sure what correct way to do it is.


In JavaScript we have a string/array method for finding a character or value in by its index…


We could write an expression with four instances of this method, one for each full stop token, of we could loop over the tokens, and iterate the string end to end on each token. I like this approach as opposed to repeated patterns and lots of verbosity.

const fullStop = [".", "?", "!", ":"];
for (let token of fullStop) {


Be sure to read up on the method before proceeding further and do some testing in your console or sandbox so you get a feel for how it works and how we need to implement it above. Let us know when you’re ready to continue.


We could write an expression with four instances of this method…

This approach will work, but as we can see is extremely verbose:

let fullStops = betterWords.filter(word => {
  return (word.indexOf('.') > -1 || word.indexOf('!') > -1 || word.indexOf('?') > -1 || word.indexOf(':') > -1);


The above should work fine, but we can see lots of pattern repetition. How could we apply the above example for loop to get straight to a count of sentences?


I appreciate the help. I was able to get the code right finally. Sorry it took awhile to reply.