I have an array like this
I would like to bring only the installments with checked = true and with payments checked = true
I have this array
0: {
checked: true,
code: 100.
paymant: Array(2)
{
0: {data: 03/12/2021, checked: true},
1: {data: 03/12/2021}
}
},
1: {
code: 100.
paymant: Array(2)
{
0: {data: 03/12/2021},
1: {data: 03/12/2021}
}
}
// Real Data
const data = [
{
checked: true,
code: 100,
payments: [
{data: 'checked', checked: true},
{data: 'not-checked'}
]
},
{
code: 100,
payments: [
{data: 'not-checked'},
{data: 'not-checked'}
]
}
];
I would like this
0: {
checked: true,
code: 100.
paymant: Array(1)
{
0: {data: 03/12/2021, checked: true},
}
},
I try to do this but no work
installments.filter(i => i.checked).filter(i => i.paymant.filter(p => p.checked))