Question: Write the function calcWordFrequencies ( ) that has a single words parameter. calcWordFrequencies ( ) is called with a string argument containing a list of
Write the function calcWordFrequencies that has a single words parameter. calcWordFrequencies is called with a string argument containing a list of words separated by spaces. The function should output those words and their frequencies to the console.
Ex: If the function call is:
calcWordFrequencieshey hi Mark hi mark";
then the console output is:
hey hi Mark mark
Hint: First use the string method split that splits a string into an array using a delimiter. Ex: words.split returns an array containing each word in words. Then place unique words in a map, where the key is the word and the associated value is the word's frequency.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
