Exploring nested loops:
for(let i = 0; i < availabilities.length; i++){
if(availabilities[i].round === 1){
// Identify objects with the same event_team_user_id and update status property
let indices = helperService.findArrayIndices(availabilities, 'event_team_user_id', availabilities[i].event_team_user_id);
for(let x = 1; x < indices.length; x++){
availabilities[x].status = availabilities[i].status;
console.log(availabilities[x]);
}
}
}
console.log(availabiities);
The code above aims to locate array objects linked to a specific round (e.g., round 1) and then synchronize the status property of other array objects that share the same event_team_user_id property.
console.log(availabilities[x]);
within the loops correctly displays the array object, yet console.log(availabiities);
presents an array where modifications made to the status property in the loops are not captured. Why are these changes not reflected in the saved array objects?