Imagine having a complex object with nested properties like this:
const obj = {
Visualization: {
Lower: [{ name: "Part", selectedValue: "60-000" }],
Upper: [{ name: "Part", selectedValue: "60-000" }],
},
Holder: {
Lower: [
{ name: "Part", selectedValue: "30-000" },
{ name: "Project Name", selectedValue: "45-000" },
],
Upper: [
{ name: "Part", selectedValue: "22-000" },
{ name: "Project Name", selectedValue: "25-000" },
],
},
};
If you wish to update all selectedValues in one go to be "0", the desired outcome should look like this:
{
Visualization: {
Lower: [{ name: "Part", selectedValue: "0" }],
Upper: [{ name: "Part", selectedValue: "0" }],
},
Holder: {
Lower: [
{ name: "Part", selectedValue: "0" },
{ name: "Project Name", selectedValue: "0" },
],
Upper: [
{ name: "Part", selectedValue: "0" },
{ name: "Project Name", selectedValue: "0" },
],
},
}
Is there a way to achieve this efficiently?
Appreciate any guidance!