Can anyone help me with converting the object retrieved from an API response into an array object? Here is the original object:
const oldObj = {
Georgia : {
notes: "lorem ipsum",
lat: "32.1656",
long: "82.9001"
},
Alabama : {
notes: "lorem ipsum",
lat: "32.3182",
long: "86.9023"
}
}
I want to transform it into the following array format:
const desireArray = [
{
name: "Georgia",
notes: "lorem ipsum",
lat: "32.1656",
long: "82.9001"
},
{
name: "Alabama",
notes: "lorem ipsum",
lat: "32.3182",
long: "86.9023"
}
];
I tried using forEach but encountered an error. Can someone provide assistance?
TypeError: oldObj.forEach is not a function
Any suggestions on how to achieve this transformation?