Skip to content
Advertisement

How to rearrange array of objects into object of objects in node js?

I have Java script array like this:

JavaScript

I need to convert above array of objects arr into object with key-value pair like below

JavaScript

I need the it like this JSON, in the form of key-value pair. How can I achieve this?

I need the data like this in order to render the output, can someone please help me with this?

Advertisement

Answer

Use Object.fromEntries like this:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement