I have an array of multi dimensional objects:
var arr = [
{
id: '10c',
name: 'item 1'
children: [
{id: '11v', name: 'Item 1 child 1'},
{id: '12c', name: 'Item 1 child 2'}
]
},
{
id: '13v',
name: 'item 2'
children: [
{id: '26e', name: 'Item 2 child 1'},
{id: '7a', name: 'Item 2 child 2'}
]
}
]
and another object of data:
var array = [
{id: '12c', name: 'New name 1'},
{id: '26e', name: 'New name 2'},
{id: '11v', name: 'New name 3'},
];
If I want to update the name value of the respective objects in arr, based on the id value in array, how would be the best way of doing that?
arr might be more than 2 levels deep, so I would like to be able to do it without having to nest multiple forEach