I'm trying to filter out objects from array "a" that match with objects in array "b" and "c". here is a link to jsfiddle to test the code.
Here is what I currently have:
const a = [{
  "name": "sondre",
  "uq_id": "abc1"
}, {
  "name": "sofie",
  "uq_id": "abc2"
}, {
  "name": "casper",
  "uq_id": "abc3"
}, {
  "name": "odin",
  "uq_id": "abc4"
}];
const b = [{
  "name": "sondre",
  "uq_id": "abc1"
}, {
  "name": "odin",
  "uq_id": "abc4"
}];
const c = [{
  "name": "casper",
  "uq_id": "abc3"
}];
function sort(a, b, c) {
  result = [];
  console.log(result);
  if (b !== null) {
    result = a.filter(function(item) {
      return !b.includes(item.uq_id);
    })
  }
  if (c !== null) {
    result = result.filter(function(item) {
      return !c.includes(item.uq_id);
    })
  }
  console.log(result);
}
sort(a, b, c);I expect the following output:
[{name="sofie", uq_id="abc2"}]
But for some reason it outputs:
[{name="sondre", uq_id="abc1"},
{name="sofie", uq_id="abc2"},
{name="casper", uq_id="abc3"},
{name="odin", uq_id="abc4"}]
Does anyone know how I can get this to work as I intended it?
 
     
     
     
    