I have implemented a filter function to remove objects from an array, but I am facing an issue. Challenge: Despite using the filter function, the elements are not being removed from the array as expected. Why are these objects still present in the array after filtering them out?
async filterPspDeliveries(pspDeliveryList: PspDelivery[]){
try {
return pspDeliveryList.filter(pspDelivery => pspDelivery.packageList.length > 0);
} catch(e) {
console.log(e);
}
}
The filter function is called within the same class here:
for (let psp of pspList){
let tmpDeliveryList = await this.filterPspDeliveries(psp.deliveryList);
psp.deliveryList = tmpDeliveryList;
}
Note: My intention is to eliminate deliveries that do not have a package list associated with them.
Your assistance on this matter would be greatly appreciated.