function count(str) { const obj = {}; str.replace(/\S/g, v => obj[v]?obj[v]++:obj[v] = 1); return obj; }