Skip to content

Instantly share code, notes, and snippets.

@BukhariH
Last active July 12, 2017 10:11
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 BukhariH/c3aa536f643dcc11c54f92f222993dde to your computer and use it in GitHub Desktop.
Save BukhariH/c3aa536f643dcc11c54f92f222993dde to your computer and use it in GitHub Desktop.
Turn an Array of Objects into an Object using Reduce
// change array & property to relevant values
const reducedObj = array.reduce(function(accum, item) {
accum[item.property] = item;
return accum;
}, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment