How can I change the status property to false of each entry with let’s say group "B", without changing the others?
Either by mutating the array or returning a new one
const personnel = [
{ id: 0, name: "Audrey Holcomb", group: "A", status: true },
{ id: 1, name: "Gwendolyn Heath", group: "B", status: true },
{ id: 2, name: "Rivas Mclean", group: "C", status: true },
{ id: 3, name: "Valeria Schneider", group: "A", status: true },
{ id: 4, name: "Leticia Keith", group: "C", status: true },
{ id: 5, name: "Nadine Woodward", group: "B", status: true },
{ id: 6, name: "Shaffer Oliver", group: "A", status: true },
{ id: 7, name: "Meghan Norman", group: "B", status: true },
{ id: 8, name: "Kyle Smith", group: "C", status: true },
]
>Solution :
Loop through array, check if group is B and then change status to false
for(let i = 0; i < personnel.length; i++) {
if(personnel[i]['group'] == 'B') {
personnel[i]['status'] = false;
}
}