Looking to remove an item from an array of objects?
[
{
"category": "CC",
"paymentOptions": [
{
"payCode": "v",
"description": "Visa"
},
{
"payCode": "m",
"description": "Master"
}
]
},
{
"category": "PayPal",
"paymentOptions": [
{
"payCode": "PY",
"description": "Paypal"
}
]
}
]
The goal is to remove the specific section from the array of objects provided above:
{
"payCode": "m",
"description": "Master"
}
After removing the specified section, the updated array should look like this:
[
{
"category": "CC",
"paymentOptions": [
{
"payCode": "v",
"description": "Visa"
}
]
},
{
"category": "PayPal",
"paymentOptions": [
{
"payCode": "PY",
"description": "Paypal"
}
]
}
]
A previous attempt using the code below did not yield the desired outcome:
this.payments.filter(x => x.paymentOptions.filter(x => x.description.toLowerCase() !="Master"))
How can I achieve this? The expected output should match the example after removal of the specific object.