Last active
August 29, 2018 21:31
-
-
Save suissa/7d458852d12aef340c2fc6c4603cd7cb to your computer and use it in GitHub Desktop.
JavaScript - groupby - filter 07
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 toNewGroup = (field) => (result, obj) => ({ | |
...result, | |
[obj[field]]: [...(result[obj[field]] || []), obj] | |
}) | |
const groups = list.reduce(toNewGroup("level"), {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment