Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayoub-bousetta/39ff89e1cd7b9102abadd613fd6b0002 to your computer and use it in GitHub Desktop.
Save ayoub-bousetta/39ff89e1cd7b9102abadd613fd6b0002 to your computer and use it in GitHub Desktop.
array.reduce((objectsByKeyValue, obj) => {
const value = keys.map(key => obj[key]).join(',');//to separate name and id
objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
return objectsByKeyValue;
}, {});
const groupByShopName = groupBy(['name','shop_id']);
AllMyCartElements= JSON.stringify(groupByShopName(existingEntries));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment