Write a program that given a phrase can count the occurrences of each word in that phrase.
For example for the input
"olly olly in come free"
olly: 2 in: 1 come: 1 free: 1
Solution in JS:
I’ve done this problem before in Ruby and it was a breeze. However, this version in JS was a bit harder because there are more test cases to account for, which was where regex came in.