I used forEach method inside for loop and this is working!
But I am not sure if this is right way or not …
I would appreciate any advice !
Thank you
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. ....';
const storyWords = story.split(' ');
const overusedWords = ['really', 'very', 'basically'];
/// count and log over used words
let count = [0, 0, 0];
const overWords = () => {
for (let i = 0; i < overusedWords.length; i++) {
betterWords.forEach((word) => {
if (word === overusedWords[i]) {
count[i]++;
}
});
console.log(`The words ${overusedWords[i].toUpperCase()} was used ${count[i]} times in the story`);
}
};
overWords();