I possess the subsequent entity:
const myObject = {
items:[
{
name: 'John',
age: 35,
children: [
{
child: 'Eric',
age: 10,
sex: 'M'
},
{
child: 'Andrea',
age: 4,
sex: 'F'
}
]
},
{
name: 'Bob',
age: 23,
children: [
{
child: 'Oscar',
age: 1,
sex: 'M'
}
]
}
]
}
When I conduct a filtration on the findings by including this:
const source = of(myObject).pipe(
map(x => x.items),
map(x => {
return x.filter(y => {
return y.children.find(y => y.sex === 'M');
})
})
);
source.subscribe(x => console.log(x));
The filtration based on gender does function as intended except I aim to eliminate the female children from the JSON. In this instance, Andrea ought to be removed from the object.
Perhaps, I lack the understanding of an alternative operator that I can apply?