added js solution to word count with optional file reading