I have a scenario where I am requesting two arrays of objectIDs
from MongoDB, and then attempting to identify the differences between the two arrays.
In addition, I am passing these arrays through express middleware using res.locals
.
Below is the code snippet for reference:
let questions = res.locals.questions;
let answers = res.locals.answers;
let outstanding = questions.filter(oid => !answers.includes(oid));
console.log("The outstanding oids: "+outstanding)
However, the result always turns out to be blank
.
I suspect it could be related to the format of data retrieved from MongoDB or the way it is stored in res.locals. Any suggestions would be greatly appreciated.
Here are examples of what the two arrays contain:
questions: ["5f522bc55dd8993e58283526","5f522ab45dd8993e58283521","5f522ba65dd8993e58283525","5f522a5e5dd8993e5828351f","5f47a9a0b1764c3e285d4666"]
answers: ["5f522ab45dd8993e58283521","5f522bc55dd8993e58283526"]