DEV Community

Discussion on: Convert an array to a map in JavaScript

Collapse
trouch profile image
trouch

Here is my short reducer :

const obj = data.reduce(
  (result, i) => ({ ...result, [i.name]: i.completed }),
  {}
);
Enter fullscreen mode Exit fullscreen mode