Created
February 26, 2017 21:49
-
-
Save NickFoden/3d1e978b8ba5647eb6589aa327ac5e00 to your computer and use it in GitHub Desktop.
2.6.6
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
https://courses.thinkful.com/fewd-001v6/project/2.6.6 | |
First a function "getTokens" takes in a value rawString which is the text you are looking at. | |
It removes any special characters so that what is left of the string is just the words. | |
Then a new function takes that string and looks at each word through the string. As it goes word to word of the string it is looking for repeats. But how it does this is it makes a new array. And adds each word from the string to the array. If the word has already been added then the value goes up by one for each time it is added again. Each time a duplicate is added to the array, and already exists its count goes up. | |
Then next function looks for the word with the highest value, or count. If it comes across a word with a higher value then the one it just looked at then that new one becomes the max count. Or highest value. Leaving you at the end with the word that got the highest value, aka was repeated the most times. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment