I am working with two arrays of objects called arr1
and arr2
If the ID in both arr1
and arr2
matches, I want to add the property names from arr1
to arr2
using JavaScript
var arr1 = [
{id: 1, name : "Helena"},
{id: 2, name : "John"}
]
var arr2 = [{
country: "MY",
details: [{
mode: "parttime",
members:[{id:1}, {id: 2}]
}]
}]
The expected output should look like this:
[{
country: "MY",
details:[{
mode: "parttime",
members: [
{id:1, name: "Helena"},
{id: 2, name: "john"}
]
}]
}]