My Map is designed to store Lectures as keys and Arrays of Todos as values.
lecturesWithTodos: Map<Lecture, Todos[]> = new Map<Lecture, Todos[]>();
Initially, I set the key in the Map without any value since I will add the Todos later.
student.semester.lectures.forEach((lecture) => {
this.lecturesWithTodos.set(lecture, []);
});
Now my goal is to assign each Todo to its corresponding Lecture key.
todos.forEach((todo) => {
this.lecturesWithTodos.get(lecture).push(todo);
});
However, I keep encountering the error message "Cannot read property 'push' of undefined." While I could work around this issue by using a string as the key, I prefer using the Lecture object for simplicity. Is there a way to make the get method work with objects as keys?