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?
CodePudding user response:
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)
});
