I need to convert an array into objects and then need to move one of object property value as a object property key name:
[
{
"description": "red",
"type": "fruit",
"item": "apple"
},
{
"description": "yellow",
"type":"fruit",
"item": "banana"
}
]
into
{
"apple": {
"description": "red",
"type": "fruit"
},
"banana": {
"description": "yellow",
"type": "fruit"
}
}
using Object.assign({}, ...arr) populates object's names into index, i need to change that index, thanks!