I have an array with registrations, inside this array is an array of students.
Now I want an array of all the students with only firstName, lastName and email.
registrations array
[
0: {
date: "2019-04-08T13:51:10.215Z"
onlyVAT: false,
students: [
0: {
email: "[email protected]",
firstName: "Bennn",
lastName: "test",
phone: "0898989"
...
}
]
}
]
What I have so far:
this.registrations.map(
registration => registration.students.map(
student => { return {
firstName: student.firstName,
lastName: student.lastName,
email: student.email
}}
)
);
but this returns an array of arrays
0: [
0: {firstName: "Bennn", lastName: "test", email: "[email protected]"},
1: ...
]
what I want is an array of (partial) student objects
[
0: {firstName: "Bennn", lastName: "test", email: "[email protected]"},
1: ...
]
ofcourse I could just loop and push to a new array but that's not what I want
mapresult, it looks like it's not.