Find the k most common words in a body of text using JavaScript

The following algorithm in JavaScript finds the k most common strings in an array of strings.

Here's some example text, a passage written by John Muir. (Because I'm using this famous nature writer as an example, I had to throw in a beautiful picture of Washington - the Olympic National Park - as the featured image for this post.)