I'm trying to figure out how to take objects from one array and merge them into objects of another array of objects. I'm using Typescript in an angular 5 application.
Array 1:
[
{
"outcomeId": 1,
"outcomeName": "draw",
"stake": 100
},
{
"outcomeId": 12,
"outcomeName": "Gandzasar Kapan FC 2",
"stake": 100000000
}
]
Array 2:
[
{
"success": true
},
{
"success": false,
"error": {
"description": "Insufficient balance 989066"
}
}
]
Result array:
[
{
"outcomeId": 9171077,
"outcomeName": "draw",
"stake": 100,
"success": true
},
{
"outcomeId": 9171076,
"outcomeName": "Gandzasar Kapan FC 2",
"stake": 100000000,
"success": false,
"error": {
"description": "Insufficient balance 989066"
}
}
]
I know how to use .map to loop over an array, but I have no idea how to do it with two and then merge them.