We're trying to wrap our heads around this for awhile and can't seem to get what we're looking for. We've attempted many loops and using lodash library to make this possible but no success. We want to loop through the arrays and return any objects and children that have the property checked:true or remove the objects that have checked: false. There are multiple levels deep and we're not able to return what we're looking for
types: [
{
name: 'Dresses',
checked: true,
collections: [
{
name: 'My Collection',
checked: true,
variations: [
{
size: 'XXS',
checked: true
},
{
size: 'XS',
checked: false
}
]
},
{
name: 'False Collection',
checked: false,
variations: [
{
size: 'XXS',
checked: false
},
{
size: 'XS',
checked: false
}
]
}
]
},
{
name: 'Tops',
checked: true,
collections: [
{
name: 'Another Collection',
checked: true,
variations: [
{
size: 'XXS',
checked: false
},
{
size: 'XS',
checked: true
}
]
}
]
}
]
Our Expected output that we are trying to generate would be:
types: [
{
name: 'Dresses',
checked: true,
collections: [
{
name: 'My Collection',
checked: true,
variations: [
{
size: 'XXS',
checked: true
}
]
}
]
},
{
name: 'Tops',
checked: true,
collections: [
{
name: 'Another Collection',
checked: true,
variations: [
{
size: 'XS',
checked: true
}
]
}
]
}
]
Which removes any object with the property checked: false
variationsmight also have nestedcollections?checked: trueobject nested in achecked: falseone?checked: flase,is just a typo? Show what you have attempted WITH the result expected, we can help fix things :)