I am trying to match values from one array object with another array and update the status if there is a match. Here's the desired output for arrObj
:
[
{ name: "Test1", status: true },
{ name: "Test2", status: false },
{ name: "Test3", status: true }
]
Check out the demo here: https://stackblitz.com/edit/github-7plax5-mu3l6a?file=src%2Fapp%2Fapp.component.ts
let arrObj = [{
name: "Test1",
status: true
},
{
name: "Test2",
status: true
},
{
name: "Test3",
status: true
}
]
let arr = ["Test1", "Test3"];
for (k of arr) {
if (arrObj.name == k) {
arrObj.status = true;
}
}
console.log(arrObj);