I have a Map which takes a Lecture as Key and an Array of Todos as value.
lecturesWithTodos: Map<Lecture, Todos[]> = new Map<Lecture, Todos[]>();
Now I first set the key of this Map without any value (because I get the Todos later).
student.semester.lectures.forEach((lecture) => {
this.lecturesWithTodos.set(lecture, []);
});
Now I just would like to set my Todos to its specific Key.
todos.forEach((todo) => {
this.lecturesWithTodos.get(lecture).push(todo);
});
But at this point it is always saying "Cannot read property 'push' of undefined". I know I can get it done, when I am using a string as Key, but I would like to use my Object instead, because it makes things easier for me later.
Is there a way how to get the get-Method working on this lecture object?
forEach.get(..)will not consider them to be equal.