[Solved] replace array of object with another array of object base on property


You can do it using Array#map() to create a new array and Array#find() to find the object in the second array

let arr=[{status:"ok"},{status:"ok"},{status:"error"}],
arr2=[{status:"error",msg:"etc","more property":!0}];

arr = arr.map(a=>{
  let fullObj = arr2.find(a2=>a2.status===a.status);
  return fullObj ? fullObj : a;
});

console.log(arr);

3

solved replace array of object with another array of object base on property