Last active
July 12, 2017 10:11
-
-
Save BukhariH/c3aa536f643dcc11c54f92f222993dde to your computer and use it in GitHub Desktop.
Turn an Array of Objects into an Object using Reduce
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
// 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