Skip to content

Instantly share code, notes, and snippets.

@zapthedingbat
Created July 21, 2017 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zapthedingbat/aa98a9c02c2862263b9d2933dcbec1b9 to your computer and use it in GitHub Desktop.
Save zapthedingbat/aa98a9c02c2862263b9d2933dcbec1b9 to your computer and use it in GitHub Desktop.
Array.from(s.split(/\W+/)
.map(a => a.toLowerCase())
.reduce((p, v) => p.set(v, (p.has(v)?p.get(v):0)+1), new Map())
.entries()
)
.sort((a,b) => b[1]-a[1])
.forEach(a => console.log(`${a[0]}:${a[1]}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment