var array = [ {item: "Coffee", price: 4}, {item: "Brownie", price: 5}, ]; const getSumByKey = (arr, key) => { return arr.reduce((accumulator, current) => accumulator + Number(current[key]), 0) } const total = getSumByKey(array, 'price') // 9