Imagine having an object like this:
{
b954WYBCC4YbsMM36trawb00xZ32: { activity1: "pending", activity2: "pending" },
pby0CAqQ1hTlagIqBTQf6l2Ti9L2: { activity1: "pending", activity2: "pending" }
}
with the initial keys being IDs retrieved from a database. The objective is to alter the values of activity1
and activity2
based on an array:
// 'data' refers to the object mentioned earlier.
const usersHaveSpecialContentAssigned = [true, false];
Object.values(data).forEach((item, index) => {
const arrayActivityProgress = Object.values(item as string[]);
if (usersHaveSpecialContentAssigned[index] === false) {
arrayActivityProgress.forEach((progress) => {
progress = 'unassigned';
console.log(progress);
});
}
});
The desired outcome following the example above should be:
{
b954WYBCC4YbsMM36trawb00xZ32: { activity1: "pending", activity2: "pending" },
pby0CAqQ1hTlagIqBTQf6l2Ti9L2: { activity1: "unassigned", activity2: "unassigned" }
}
Is there a way I can accomplish this? My current method isn't effectively updating the values.