class fruitCollection extends Array { sum(key) { return this.reduce((a, b) => a + (b[key] || 0), 0); } } const fruit = new fruitCollection(...[ { description: 'orange', Amount: 50}, { description: 'orange', Amount: 50}, { description: 'apple', Amount: 75}, { description: 'kiwi', Amount: 35}, { description: 'watermelon', Amount: 25 },]); console.log(fruit.sum('Amount'));