Here are two arrays which the first array is the main one and I need to update the value of every object that exist is the second array recursively
by comparing their names.
Actually the first array is my form schema that might change occasionally And the second on is user filled data (schema + values). As user can update their filled forms, I need to show the new schema along with filled values of each object.
Main Array:
[
{
name: '6tb76sc'
},
{
name: 'df45hf'
},
{
name: 'ctb360f',
childs: [
{
name: 'h83gus'
childs: [
{
name: 'u8yh49'
}
]
}
]
},
{
name: 'i6g7bau'
}
]
Second Array:
[
{
name: '6tb76sc',
value: 'test'
},
{
name: 'ctb360f',
childs: [
{
name: 'h83gus',
value: 'test1'
childs: [
{
name: 'u8yh49',
value: 'test2'
}
]
}
]
},
]
Needed output:
[
{
name: '6tb76sc',
value: 'test'
},
{
name: 'df45hf'
}
{
name: 'ctb360f',
childs: [
{
name: 'h83gus',
value: 'test1'
childs: [
{
name: 'u8yh49',
value: 'test2'
}
]
}
]
},
{
name: 'i6g7bau'
}
]