Pages

filtre and co 2

function date(min,max){
  return function( {date} ){
    if (new Date(min) <= new Date(date) && new Date(date) <= new Date(max)) {return true}
    else {return false}
  }
}

const myagg = function(acc, cur)  {
  if (!acc[cur.item]) acc[cur.item] = 0;
  acc[cur.item]+=cur.price*cur.quantity;
  return acc
}

const filtre = products.filter(date('2014-01-01','2015-01-01'))
                       .reduce( myagg,{})
console.log(filtre)


code