data: {
goodReceiveNote:{ id:1,netTotal: null}
poDetailsList:[
0:{id:1,subTotal:300},
1:{id:1,subTotal:200}
]
}
How to get the sum of poDetailsList subTotal and Assign it to the netTotal in goodReceiveNote in react.
Use the array reduce in combinaison with Object.values
const total = Object.values(data.poDetailsList).reduce((a,b) => a + b.subTotal, 0)