I have an array of objects that looks like this:
var data = [{costOfAirtickets: 2500, costOfHotel: 1200},{costOfAirtickets: 1500, costOfHotel: 1000}]
var data = [{costOfAirtickets: 2500, costOfHotel: 1200},{costOfAirtickets: 1500, costOfHotel: 1000}]; var result = [data.reduce((acc, n) => { for (var prop in n) { if (acc[prop]) acc[prop] += n[prop]; else acc[prop] = n[prop]; } return acc; }, {})] console.log(result)