Word count in javascript