I have this array of objects and I'm trying to retrieve the student that match a criteria where active is true and id or token not equal to null. The result I get has token == null. Not sure what i'm doing wrongly please.
books = [{
student: {
studentInformation: [{
active: true,
id: "92839"
}]
}
},
{
student: {
studentInformation: [{
active: true,
token: null
}]
}
},
{
student: {
studentInformation: [{
active: false,
token: "eytqwedgd"
}]
}
},
{
student: {
studentInformation: [{
active: true,
id: null
}]
}
}
]
let students = books.filter(stu =>
stu.student.studentInformation.every(y => y.active ===
true && (y.id !== null || y.token !== null)))
console.log(students);