const getSumByKey = (arr, key) => { return arr.reduce((accumulator, current) => accumulator + Number(current[key]), 0) } arr = [{x:1}, {x:3}] getSumByKey(arr, 'x') // returns 4