Last active
September 5, 2019 03:36
-
-
Save brianfiszman/82f8da9a1653c2a985786135b44276b8 to your computer and use it in GitHub Desktop.
Group by repetitions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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