Have an array as
result1= [
[{name:"a",fruit:"apple"},{name:"b",fruit:"banana"}],
[{name:"o",fruit:"orange"}],
[{name:"g",fruit:"grapes"},{name:"s",fruit:"strawberries"}]
]
and
result2 =[
{country:"japan",color:"red"},
{country:"NewZealand",colour:"yellow"},
{country:"srilanka",colour:"green"}
]
would need to insert a property having arrays inside the second with the indexes being same...length of the two arrays are same...resulted array should be
result3 = [
{country:"japan",color:"red",newproperty:"[{name:"a",fruit:"apple"},{name:"b",fruit:"banana"}]"},
{country:"NewZealand",colour:"yellow",newproperty:"[{name:"o",fruit:"orange"}]"},
{country:"srilanka",colour:"green",newproperty:"[{name:"g",fruit:"grapes"},{name:"s",fruit:"strawberries"}]"}
]
i have tried with the below code
result3 = (result2.map((o, i) => Object.assign(o, result1[i])))
result of this adding each object of array rather than whole array itself from result1 to result2
Have tried with the code to add a property using map result fluctuates...please help with this