``````    So my goal is to solve an agorithm for this task:
``````

For the overused words, remove it every other time it appears.

``````let story = 'Last weekend, I took literally the most beautiful bike ride of my life. The route is called "The 9W to Nyack" and it actually stretches all the way from Riverside Park in Manhattan to South Nyack, New Jersey. It\'s really an adventure from beginning to end! It is a 48 mile loop and it basically took me an entire day. I stopped at Riverbank State Park to take some extremely artsy photos. It was a short stop, though, because I had a really long way left to go. After a quick photo op at the very popular Little Red Lighthouse, I began my trek across the George Washington Bridge into New Jersey.  The GW is actually very long - 4,760 feet! I was already very tired by the time I got to the other side.  An hour later, I reached Greenbrook Nature Sanctuary, an extremely beautiful park along the coast of the Hudson.  Something that was very surprising to me was that near the end of the route you actually cross back into New York! At this point, you are very close to the end.';

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

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

let storyWords = story.split(' ')

//console.log(storyWords.length)

let betterWords = storyWords.filter(function(word) {
return !unnecessaryWords.includes(word)
})

//console.log(betterWords)

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

for(word of storyWords){
if(word === "really"){
reallyCount +=1
} else if(word === "very"){
veryCount +=1
} else if(word === 'basically'){
basicallyCount +=1
}

}

let numOfOverWords = () => {
console.log('really: ' + ' ' +reallyCount + ' ' + 'very: ' + ' ' + veryCount + '' + ' '+ 'basically: ' + basicallyCount)
}

numOfOverWords()

//console.log(numOfOverWords())

const evenOverUsed = betterWords.forEach(word => {
if(word === overusedWords % 2 === 0){
return betterWords.includes(word)
} else {
return !betterWords.includes(word)
}

})

console.log(evenOverUsed)

let sentenceCount = 0;
for(word of storyWords){
if(word[word.length - 1] === "!" || word[word.length - 1] === "." || word[word.length - 1] === "?"){
sentenceCount +=1
}
}

//console.log('sentence:',sentenceCount)
let wordCount = story.length
let abusedWords = numOfOverWords;

const formatData = (storyLength,sentence,overlyUsed) => {
console.log('word count: ' + storyLength);
console.log('Sentence Count: ' + sentence);
console.log('How Many times overlyused words used:' + overlyUsed);
}

//formatData(wordCount,sentenceCount,numOfOverWords)

``````

Hello @anthonybishop8155039, welcome to the forums! Did you have any specific questions about this code? Also, in future, can you please post your code formatted? To format code, press this button:

and insert the code between the back ticks:

Sorry about that still new to this kind of. I just edited right now. Did I format it right?

I just wanted to see what I am doing wrong . I am trying to remove overused words every other time its used.

``````const evenOverUsed = betterWords.forEach(word => {
if(word === overusedWords % 2 === 0){
return betterWords.includes(word)
} else {
return !betterWords.includes(word)
}

})

console.log(evenOverUsed)
``````

Yes, you did!

Can you explain to me what this line does, please?

Its suppose to pull all the even words from overused words.

Ok. What does it do specifically? Can you give a explanation of what each part does?
Hint: what are you performing `% 2 === 0` on?

so the overusedWord % 2 === 0 isnt that the formula for even. i used the for eacheach to say for each word that is in a even index number include it in ny betterwords else dont including

Yes, it is. But if you’re using `overusedWord` for this logic expression, what is this doing:

im trrying to tell it to grab all the even words in it

When you use a logical expression, you can only have one thing equal to, greater than, etc-to another:

``````var === var2  //or the like
``````

if you want more than one condition, you must use the `and operator: &&`, the `or operator: ||` or the `not operator: !`:

``````var1 === var2 && var2 === var3 //or the like
``````

In your case, I would assume you would want to use an and operator `&&`, as you are checking to see if `word equals overusedWords and the position is an even position`.

To better help with the rest of the code, could you please tell me what `overusedWords` is-is it an array, and string, etc.

overusedWords is an array. Of all the overUsed words that is inside my story and im trying to delete everyother overUsedWords in my story.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.