I have this sample data and manage to use chain of .filter, .map and .reduce to get the total course score for one student. My question is how do I show the total course score for EACH student name? If I remove the filter, it will show the total score for ALL students instead of EACH student.
var data = [
{ name: "John", courseName:"Javascript", courseScore: 85 },
{ name: "John", courseName:"C#", courseScore: 72 },
{ name: "John", courseName:"SQL", courseScore: 91 },
{ name: "Mike", courseName:"Javascript", courseScore: 68 },
{ name: "Mike", courseName:"C#", courseScore: 80 },
{ name: "Mike", courseName:"SQL", courseScore: 79 }
];
// John's total score for all the courses.
var scoreOfJohn = data
.filter(x => x.name === 'John')
.map(x => x.courseScore)
.reduce((x, y) => x + y);
console.log(scoreOfJohn);