DEV Community

loading...

Discussion on: How to convert an array into an object in javascript

nicolege profile image
nicole-ge

to understand the code a bit better, how I have to adjust it to get the following result:

[
{"name":"Area 1","value":3},
{"name":"Area 2","value":3},
{"name":"Area 2","value":1}
];

Thread Thread
fetishlace profile image
fetishlace

From that?
let arr = [
{"name":"Product 1","series":{"name":"Area 1","value":3}},
{"name":"Product 2","series":{"name":"Area 2","value":3}},
{"name":"Product 1","series":{"name":"Area 2","value":1}},
]
U can just remap it
arr.map(x=>x.series)