Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The function getTokens -> It grabs whatever string it receives from the user, makes it into lowercase, sorts it out (since it was
- not defined in this instance, it will just do an automatic one), filter it according to if it was a string or not, and then split the
- string properly in accordance with what it was given. Function mostFrequentWord...most of the code makes sense, it is getting the
- previous function getTokens, declaring it as 'words' and then using that to go through a for loop, which is saying that as long as
- the variable i does not exceed the maximum length of word then keep increasing and there is also a condition on top of that as well.
- The extra condition is that while going through the words, if there are more than 1 word then increase the count of wordFrequency by 1
- but if not, then just make the word in the array equal to one. The only problem I see though in this code would be that the person
- let wordFrequencie = {}; I thought arrays had to equal []? Using the object.key and the array for the function wordFrequency, they set
- those to other variables. Then they set a loop for the variable so that the code knows what the most frequent word will end up being
- with it setting the current max key/count to help it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement