I am trying to filter an array as I have a million times in the past but it's not working.
locations = city.locations.filter(
(l) => {
console.log(l._id);
console.log(req.query.locationId);
console.log(l._id === req.query.location);
return l._id === req.query.location;
}
)
Console output:
l1dr2jmg42lb2sgiudi
l1dr2jmg42lb2sgiudi
false
The first two console.log print identical strings but the third prints false??!?
I checked that city.locations is an Array and both l._id and req.query.locationId are a string.
console.log('"' + l._id + '"'). It is silly, but it happens.===to==in the 3rdconsole.logwhat do you get?