so i have this array and i want to return the sum of lci and the sum of mci with a reduce function
const data = [{ option:{ lci: 1, mci: 2 } }, { option:{ lci: 3, mci: 4 } }, { option:{ lci: 5, mci: 6 } }];
i have tried this but it's not working:
data.reduce( (previousValue, currentValue) => {
return {
totalLCI: previousValue.option.lci + currentValue.option.lci,
totalMCI: previousValue.option.lci + currentValue.option.lci,
};
})