I'm trying to add objects to an existing array if the condition is true.
Below is my code
RequestObj = [{
"parent1": {
"ob1": value,
"ob2": {
"key1": value,
"key2": value
},
},
},
{
"parent2": {
"ob1": value,
"ob2":{
"key1":value,
"key2": value
}
}
}]
Here I'm trying to add an object to the RequestObj array if the condition is true. I could do RequestObj.push(). But i don't know how to added in parent1 object.
if (key3 !== null) {
// add this below object to parent1 object
"ob3": {
"key1": value,
"key2": value
}
}
I'm not able to find any solution. Please help