const countWords = str => str .replace(/[^\w\s]/gi, '') .toLowerCase() .split(/\s+/g) .reduce((result, word) => { result[word] = (result[word] || 0) + 1 return result }, {})