data = [
[
{
key: 'test1',
value: '0'
}
],
[
{
key: 'test2',
value: '0'
},
{
key: 'test3',
value: '0'
}
]
];
I need to transform it into the desired format shown below:
formattedData =
[{
'test1':'0',
},
{
'test2':'0',
'test3':'0'
}]
I attempted to tackle this issue with the following code but couldn't succeed. Can anyone assist me in solving this problem? Thank you.
let formattedData = []
let counter = 0
for(let item of this.data){
for(let prop of item){
formattedData[counter].push(prop.key:prop.value)
}
counter++;
}