Currently, I am using a filtering method that is working perfectly, but I am facing an issue where I lose my original Array when there are no dates between the specified range (as expected). Is there a way to prevent this data loss?
The reason I need to retain my Array is that I want to filter it without having to reload when a new date is provided by the user. However, this is challenging when the Array becomes empty.
Below is the function I am using:
filterByDate(d) {
this.orders = this.orders.filter(
(element) =>
element.order.orderdate >= d[0] &&
element.order.orderdate <= d[1]
);
},
In this function, d[0] represents fromDate and d[1] represents toDate. Your assistance is appreciated. Thanks.