Created
January 7, 2019 22:04
-
-
Save sethdavis512/63fb003c0c8aec8254e79118a4e51e53 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 groupBy = (array, groupKey) => { | |
| return array.reduce((acc, cur) => { | |
| if (acc[cur[groupKey]]) { | |
| acc[cur[groupKey]].push(cur); | |
| } else { | |
| acc[cur[groupKey]] = [cur]; | |
| } | |
| return acc; | |
| }, {}); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment