Skip to content

Instantly share code, notes, and snippets.

@brianfiszman
Last active September 5, 2019 03:36
Show Gist options
  • Save brianfiszman/82f8da9a1653c2a985786135b44276b8 to your computer and use it in GitHub Desktop.
Save brianfiszman/82f8da9a1653c2a985786135b44276b8 to your computer and use it in GitHub Desktop.
Group by repetitions
const arr = [true, 'tset', 'test', 'test', 'tset', true, 1, 3, 1]
const group = arr.reduce(
(a, b) => ({
...a,
[b]: (a[b] || 0) + 1
}), {}
)
console.log(group)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment