Here is an example of an array:
let array = [
{1: {
"date": "2014-04-23 00:00:00",
"volumetrie": "22458"
}},
{2: {
"date": "2014-05-02 00:00:00",
"volumetrie": "30585"
}},
{3: {
"date": "2014-03-27 00:00:00",
"volumetrie": "49536"
}}
]
I want to transform it into this format:
let array = [
{
"date": "2014-04-23 00:00:00",
"volumetrie": "22458"
},
{
"date": "2014-05-02 00:00:00",
"volumetrie": "30585"
},
{
"date": "2014-03-27 00:00:00",
"volumetrie": "49536"
}
]
I attempted to make the change using this code:
array.forEach(function(e){
newData.push(e);
});
Unfortunately, this approach did not work due to push not being supported.
Another method I tried was:
let newData = {};
array.forEach(function(e){
newData = {...newData, ...e};
});
Despite my efforts, this solution was also unsuccessful. Do you have any suggestions on how to achieve the desired result?