I'm having some problems with arrow functions and filtering array of objects by value of date.
I've tried to filter it but it returns full array, and did'nt working as it must be.
in the end i've got to return items - objects in array which expiration date is bigger than today. It must be arrow function
const menuItems = [{
name: 'Hamburger',
expirationDate: '09-24-2019'
},
{
name: 'Chicken',
expirationDate: '10-03-2019'
},
{
name: 'Hot-Dog',
expirationDate: '03-24-2019'
},
];
let today = new Date();
let dd = today.getDate();
let mm = today.getMonth();
let yyyy = today.getFullYear();
if (dd < 10) {
dd = '0' + dd;
}
if (mm < 10) {
mm = '0' + mm;
}
today = mm + '-' + dd + '-' + yyyy;
console.log(today);
const filterByExpiration = (items) => {
menuItems.filter(function() {
return items.expirationDate > today;
})
};