How to destructure an array, so that a nested array is transformed into an object including the value as the key, and the following data as the object?
Like here:
const carsList =
[
{
"id": 1,
"name" : "Fiat",
"description" : "blabla",
"options": [
{
"option" : "electric windows",
"quantity" : 4,
"color": "none"
},
{
"option" : "air bags",
"quantity" : 2,
"color": "white"
}
]
}, ...
]
to:
const carsList =
[
{
"id": 1,
"name" : "Fiat",
"description" : "blabla",
"options": {
"electric windows": {
"quantity" : 4,
"color": "none"
},
"air bags": {
"quantity": 2,
"color": "white"
}
}
},...
]