js two value from array after reduce

Solutions on MaxInterview for js two value from array after reduce by the best coders in the world

showing results for - "js two value from array after reduce"
Tommaso
03 Jul 2017
1cartTotal(): void {
2
3    const {total, quantity} = this.carrello.plu.reduce((acc, item) => { 
4      acc.quantity += item.qta;
5      acc.total = acc.total + (item.prezzo * item.qta);
6      return acc;
7    }, {total:0, quantity:0});
8
9	this.cartCount.next(acc.quantity);  // emit whatever you want to emit.  
10}
11
12console.log('Total Price', total, 'Total Quantity', quantity);