Trying to explain this might be a bit tricky, but hopefully I am able to convey my message clearly. Let's say you have an array structured like this:
mainArray: [
{
name: '',
age: null,
gender: null,
hobbies: []
}
],
Now, you want to update this array by adding the values from another array (without replacing any existing keys), which looks like this:
const newArrayToAddToMainArray = [{
age: 25,
name: "Alice"
gender: "female"
},
{
age: 30
name: "Bob"
gender: "male"
}]
So that your mainArray
ends up looking like:
const mainArray = [{
age: 25
name: "Alice"
gender: "female"
hobbies: []
},
{
age: 30
name: "Bob"
gender: "male"
hobbies: [],
}]
Is there a way to accomplish this task?