I have an array with items. Each of these items have the following values
invoice_rows: [
{ item: '', qty: '', price: '' }
],
For each invoice item there is a row added to the array but I want to get the total cost of all these items. So let's do some math, I have the following array with data
invoice_rows: [
{ item: 'item1', qty: '4', price: '10' }
{ item: 'item2', qty: '2', price: '10' }
{ item: 'item3', qty: '5', price: '5' }
],
The total cost should be the sum of the qty * price for each row. Making the total 40 + 20 + 25 = 85. How can I do this with the reduce method?