Created
October 18, 2019 17:11
-
-
Save challey17/6c3131d4994de4db13d7aecc4c9cc3d8 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
On line 7, the variable “words” is created. The text is trimmed down to only lower case words with no punctuation by the getTokens function. | |
Line 8 wordFrequencies is declared as a function | |
Line 9-15 the text is checked to see if a word is repeated and if so how many times. | |
Line 16 the word used with the most frequency is placed in the first position of an array | |
Line 17 the maxCount is declared as the number of times a word is used | |
// maxCount = number of times a word is used | |
// maxKey = the word itself | |
Line 19-24 the words are counted and the the word with the highest count, maxKey, is given the number value of how many times it was counted. | |
Line 25 the function mostFrequentWord, at long last, returns the most frequently used word in the text (maxKey). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment