Last active
August 27, 2018 13:12
-
-
Save bee-san/eb5ac1d1dbea19b043d863855930a7a1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function countWords(words){ | |
| // returns a dictionary of {WORD: COUNT} where count is | |
| // how many times that word appears in "words". | |
| const unique_words = uniqueWords(words); | |
| let dict = {}; | |
| // for every single unique word | |
| for (let i = 0; i <= unique_words.length - 1; i++){ | |
| dict[unique_words[i]] = 0 | |
| // see how many times this unique word appears in all words | |
| for (let x = 0; x <= words_without_stopwords.length -1; x++){ | |
| if (unique_words[i] == words[x]){ | |
| dict[unique_words[i]] = dict[unique_words[i]] + 1; | |
| } | |
| } | |
| } | |
| return dict; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment