Created
January 13, 2019 08:27
-
-
Save cosminpopescu14/946ff4af180ca93a897911d2c537560a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let story = "really very basically bla bla ba afara este frig. Ana are mere. Javascript drives me very mad. But basically it is used everywhere. Very Ana Ana Ana really"; | |
let overUsedWords = ["really", "very", "basically", "Ana"]; | |
let storyWords = story.split(" "); | |
let freq = {} | |
for (storyWord of storyWords) | |
{ | |
for(overUsedWord of overUsedWords) | |
{ | |
if(storyWord.toLowerCase() === overUsedWord.toLowerCase()) | |
{ | |
if(freq[overUsedWord]) | |
{ | |
freq[overUsedWord]++; | |
} | |
else | |
{ | |
freq[overUsedWord] = 1; | |
} | |
} | |
} | |
} | |
console.log(freq) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment