I have a nested array like this
array = [[1, 698],[32, 798],[69, 830],[95, 500]]
I want to have a function that return the result in this format
[
{
id: 1,
score: 698
},
{
id: 32,
score: 798
},
{
id: 69,
score:830
},
..... the rest of the array
]
I did use a for loop but with no success, and I have no idea on how to aproach the situation.
for(var i = 0; i <= array.lenght ; i++){
var obj={}
var res = []
res.push(array[i])
}
resin each iteration from scratch, so you don't push the mapped data to the same array each time