I have two arrays which consist of custom made objects. They look like the following:
courses: [
{Course: "Design", ECST: 5},
{Course: "Construction", ECTS: 10}
],
statistics: [
{Course: "Design", Hours: 2},
{Course: "Design", Hours: 2},
{Course: "Construction", Hours: 2},
{Course: "Construction", Hours: 2},
],
I want to calculate the sum of hours from the "statistics" array of each Course. The problem is that the user adds the courses, so I can not say === "Design", but I have to compare them based on the courses added. So my questions is this: How can I calculate the total amount of Hours from each course in the "statistics" Array? Is there a way to simply compare the courses allready added? Something like all courses which equals each other, get the hours?