Adding Word Count in JavaScript