Currently, I am working on a data structure that looks like this:
masterObject: {
Steps: [
{
step: {
required: false,
},
step: {
required: false,
},
step: {
required: false,
},
},
]
}
My goal is to iterate through the array of steps and verify if each step object contains the 'required' property set to false. If all steps are indeed not required, then I want to add a new property to the masterObject called
masterObject.isObjectWithNoRequiredSteps = true;
Once this code snippet runs, the updated masterObject will resemble this:
masterObject: {
Steps: [
{
step: {
required: false,
},
step: {
required: false,
},
step: {
required: false,
},
},
]
isObjectWithNoRequiredSteps: true
}
If there is an instance where one of the step objects has the required property set to true, then I want to update the new property to false like so:
masterObject.isObjectWithNoRequiredSteps = false;
masterObject: {
Steps: [
{
step: {
required: true,
},
step: {
required: false,
},
step: {
required: false,
},
},
]
isObjectWithNoRequiredSteps: false
}
I am seeking advice on the best method for implementing this functionality at the higher level object.