When presented with the following data structure:
{
"time_1": 20,
"time_2": 10,
"time_3": 40,
"time_4": 30
}
and expecting a result in this format:
[
{
"key1": "time_1",
"key2": 20,
},
{
"key1": "time_2",
"key2": 10,
},
{
"key1": "time_3",
"key2": 40,
},
{
"key1": "time_4",
"key2": 30,
}
]
Is there a way to convert an object into an array using JavaScript? I have revised my initial question.