Last active
December 28, 2019 06:04
-
-
Save damnDasha/2cf0a53ad1f6f873bbad77fd1731be23 to your computer and use it in GitHub Desktop.
grokking
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
function getTokens calls a rawString | |
toLowerCase converts this to lower case | |
split -- splits a string into an array of substrings, and returns the new array. In this case, any false strings | |
will not appear in the resulting array. | |
function mostFrequentWord calls text using a good ol fashioned loop. a for loop executes a block of instructions a set | |
number of times. | |
this loop will execute as many times as the parameters appear in the text. | |
the parameters are: if i is equal to or less than word.length, increment i each time the code block in the | |
loop is executed. | |
The Object.keys() method returns an array of a given object's own enumerable property names, | |
in the same order as with a normal loop. In this instance we get back the keys of that object as an array. | |
In this instance the object.Keys will find the values for all the word frequencies, or how often they appear. | |
if (wordFrequencies[word] > currentMaxCount) | |
Basically says if word frequencies is greater than current max count, then return the value of the current max key.. | |
which is equal to?? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment