Exercism JS: Word Count

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: 

screen-shot-2017-01-04-at-9-40-02-pm

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.

Advertisements
Exercism JS: Word Count

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s