"254": {
"Term 1": {
0: { id: 1, Students: 29 },
1: { id: 1, Students: 20 },
2: { id: 1, Students: 11 }
},
"Term 2": {
0: { id: 1, Students: 9 },
1: { id: 1, Students: 10 },
2: { id: 1, Students: 22 }
}
},
"251": {
"Term 1": {
0: { id: 1, Students: 2 },
1: { id: 1, Students: 5 },
2: { id: 1, Students: 10 }
}
}
OUTPUT should be like -
For 254 - Total count of student should be cumulative of all the term 101
For 251 - Total count of student should be cumulative of all the term 17
254 and 251 is classID. So, in one class there are multiple terms and I need to fetch total student count for all the term in that class.
I tried using reduce but not getting expected output.
this.progressReportList = data; // in this list I am getting data
this.progressReportList.reduce((acc, ele) => {
console.log("ele : ", ele);
return acc + parseInt(ele.Students);
}, 0);
Please advice!