JavaScript: Map an array of objects to a dictionary - DEV Community

PHOTO EMBED

Tue Nov 16 2021 15:05:08 GMT+0000 (UTC)

Saved by @arielvol

let dictionary = data.reduce((a,x) => ({...a, [x.id]: x.country}), {})
content_copyCOPY

https://dev.to/devtronic/javascript-map-an-array-of-objects-to-a-dictionary-3f42