Last active
October 14, 2019 16:19
-
-
Save IOIO72/aaae4f48b86cb0fd62d87d81d36cda82 to your computer and use it in GitHub Desktop.
An array of objects of same structure is given. Each object contains a property `label` besides other properties. Same labels are equal accross the objects. The goal is to group the objects by the labels.
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
// Get an array of all labels with unique entries. | |
const uniqueLabels = [...new Set(apps.map(item => item.label))]; | |
// Transform the original array of objects to an array of label groups. | |
const groupedApps = uniqueLabels.map(label => ({ label, stores: apps.filter(app => app.label.includes(label)) })); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment