Is there a way to update an array of objects with values from another array of objects?
Consider these two arrays:
const originalArray = [
{id:'a',html:'',user:''},
{id:'b',html:'',user:''},
{id:'c',html:'',user:''},
];
const newArray = [
{id:'a',html:'',user:''},
{id:'b',html:'',user:''},
{id:'c',html:'',user:''},
{id:'d',html:'<p>Hello World</p>',user:'TEST USER'},
{id:'e',html:'<p>Hello World TWO</p>',user:'TEST USER TWO'},
];
I am looking to merge the new values from newArray
into originalArray
.
The expected result should be:
[
{id:'a',html:'<p>Hello World</p>',user:'TEST USER'},
{id:'b',html:'<p>Hello World TWO</p>',user:'TEST USER TWO'},
{id:'c',html:'',user:''},
];