Answers for "js two value from array after reduce"

0

js two value from array after reduce

cartTotal(): void {

    const {total, quantity} = this.carrello.plu.reduce((acc, item) => { 
      acc.quantity += item.qta;
      acc.total = acc.total + (item.prezzo * item.qta);
      return acc;
    }, {total:0, quantity:0});

	this.cartCount.next(acc.quantity);  // emit whatever you want to emit.  
}

console.log('Total Price', total, 'Total Quantity', quantity);
Posted by: Guest on September-07-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language