Skip to content

Instantly share code, notes, and snippets.

@csierra15
Created September 6, 2017 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csierra15/4bd4581f873e266cb4103f0a245ad648 to your computer and use it in GitHub Desktop.
Save csierra15/4bd4581f873e266cb4103f0a245ad648 to your computer and use it in GitHub Desktop.
Word Frequency Challenge
-Function getTokens takes a single argument (rawString).
getTokens should return rawString to lower case letters, split after certain characters INTO a new array,
removed of any false items, and sorted into order (alphabetical).
-Function mostFrequentWord takes single argument (text).
This function holds a loop that searches through the (text) for the frequency of the words used.
wordFrequencies creates an Order of the words and the number of times it has appeared.
The loop starts at the first word in the getToken array, and counts the frequency of the word.
If the word has not yet appeared, it is added to the Order.
-The currentMaxKey sets the first word in the array as the max,
then currentMaxCount counts if any other words are greater than or less than the current max.
If it is greater than the current max, then it becomes the current max.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment