Looking for a way to filter an object array of products where each element has a string property called addedDate. The goal is to only include products that were added within the last 3 days.
let now = new Date();
let latestProducts: IProduct[];
latestProducts = this.products.filter(product => {
new Date(product.addedDate).getDate() >= (now.getDate() - 3)});
console.log(latestProducts);
I'm running into an issue where nothing is being filtered from the products list. Can someone offer some guidance on how to fix this? Thanks!