Skip to content

Instantly share code, notes, and snippets.

@lucalanca
Last active February 13, 2017 16:01
Show Gist options
  • Save lucalanca/5f4d5f56779ad4ca11b19f9c652c81c2 to your computer and use it in GitHub Desktop.
Save lucalanca/5f4d5f56779ad4ca11b19f9c652c81c2 to your computer and use it in GitHub Desktop.
transformArrayToDictionary
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