Created
April 10, 2020 12:46
-
-
Save nkhil/8c4980d91e16e9bd415e9014ef2e6edf 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 property = obj[key]; | |
// obj[key] here will be '1991'. | |
acc[property] = acc[property] || []; | |
// At this point acc['1991'] doesn't yet exist, so it will be an empty array. This step is important as it checks if acc['1991'] exists, and if not, creates it and assigns a value of an empty array. | |
acc[property].push(obj); | |
// Here, all we're doing is pushing our object into the right group |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment