Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. The function getTokens -> It grabs whatever string it receives from the user, makes it into lowercase, sorts it out (since it was
  2. 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
  3. string properly in accordance with what it was given. Function mostFrequentWord...most of the code makes sense, it is getting the
  4. previous function getTokens, declaring it as 'words' and then using that to go through a for loop, which is saying that as long as
  5. 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.
  6. 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
  7. 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
  8. let wordFrequencie = {}; I thought arrays had to equal []? Using the object.key and the array for the function wordFrequency, they set
  9. 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
  10. with it setting the current max key/count to help it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement