I have received a JSON response structured as follows.
[
{
"week":1,
"win":10,
"lose":[
{
"week":2,
"count":1
},
{
"week":3,
"count":0
}
]
},
{
"week":2,
"win":7,
"lose":[
{
"week":3,
"count":1
},
{
"week":4,
"count":3
}
]
},
{
"week":3,
"win":8,
"lose":[
{
"week":4,
"count":1
}
]
}
]
My goal is to transform this data into an array with the "win" counts and "count" values nested within the "lose" object. Is there a more efficient solution to achieve this without resorting to for loops?
Expected result:
[
[10, 1, 0],
[7, 1, 3],
[8, 1]
]
Considering that I am working on the front end, what would be the optimal approach to tackle this task?