DEV Community

Discussion on: JavaScript Katas: Count the number of each character in a string

Collapse
 
jonrandy profile image
Jon Randy 🎖️

Shorter version:

const result = [...text].reduce(
  (acc,val)=>(acc[val]=~~acc[val]+1,acc), {}
)
Collapse
 
theonlybeardedbeast profile image
TheOnlyBeardedBeast

Nice!