I am trying to compare the values of two different arrays, if the user.id of the volunteer iteration matches the id of the userVolunteer iteration, I want that entry to be filtered out of the volunteers array
current attempt:
const newBirds = volunteers.filter((volunteer) => {
return volunteer.user_id !== userVolunteers.some((vol) => vol.id)
});
newBirds currents returns the volunteers array without filtering any of the entries? Any advice?
You need to put the logic of comparison inside the some
callback:
const newBirds = volunteers.filter((volunteer) => {
return userVolunteers.some((vol) => volunteer.user_id !== vol.id)
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.