4. Count Word Frequencies

Write a function that takes a string and returns an object representing the frequency of each word. Words should be considered case-insensitive and separated by whitespace.

Examples:

Input: text = "Hello world hello"
Output: { "hello": 2, "world": 1 }
Explanation: Counts each word ignoring case.
Input: text = "Test case test"
Output: { "test": 2, "case": 1 }
Explanation: Multiple occurrences are handled.
SolutionJavaScript
Test Results
Click "Run Code" to test your solution