//array.reduce(function(total, currentValue, currentIndex, arr), initialValue)
//to find total price
let items = [
{item:"sample1", price:10},
{item:"sample2", price:15},
{item:"sample3", price:25}
]
let sum = items.reduce((total, currentValue)=>{
return total+currentValue.price
},0)
console.log(sum)
Editor is loading...