JavaScript mengurangi fungsi untuk mendapatkan jumlah nilai objek

javascript reduce function to get sum of specific object property 

let records = [
  {name: 'ball',amount: 20},
  {name: 'toy',amount: 40},
  {name: 'book',amount: 30}
]

const amount = records.reduce((acc, cv) => {
    return acc + cv.amount;
  }, 0);

// amount = 90
Runtime Terror