const data = [
{ id:4, name:'sam',stats:[{id:1, partnerId:4, applicatiions:4, drafts:5},{id:2, partnerId:4, applicatiions:1, drafts:2}]},
{ id:5, name:'kam',stats:[{id:1, partnerId:5, applicatiions:2, drafts:3}]},
{ id:6, name:'jam',stats:[]},
{ id:7, name:'ram',stats:[{id:1, partnerId:7, applicatiions:9, drafts:5},{id:2, partnerId:7, applicatiions:2, drafts:5}]}
]
const items = data.map(item=> {return {...item, applicatiions: item.stats.reduce((partialSum, stat) => partialSum + stat.applicatiions ,0), drafts: item.stats.reduce((partialSum, stat) => partialSum + stat.drafts ,0)}});
console.log(items.map(({stats, ...rest}) => rest ))
0
solved How to get count values from nested array of objects in react [closed]