Last active
February 13, 2017 16:01
-
-
Save lucalanca/5f4d5f56779ad4ca11b19f9c652c81c2 to your computer and use it in GitHub Desktop.
transformArrayToDictionary
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
export const transformArrayToDictionary = (items, idKey) => items.reduce((acc, item) => { | |
const { [idKey]: title, ...rest } = item; | |
return { | |
...acc, | |
[title]: rest | |
} | |
}, {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment