Skip to content

Instantly share code, notes, and snippets.

@kbk0125
Created August 6, 2018 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbk0125/c3ed8c3aea23414a8f66822e3db2a0f6 to your computer and use it in GitHub Desktop.
Save kbk0125/c3ed8c3aea23414a8f66822e3db2a0f6 to your computer and use it in GitHub Desktop.
let box1= ["juice", "sandwich", "chips", "yogurt"];
let box2 = ["milk", "sandwich", "carrots", "chips"];
let total = box1.concat(box2);
let answer = total.filter(function(item){
//the items that are not included in box2 but are in total
let justArr1 = !box2.includes(item);
//the items that are not included in box1 but are in total
let justArr2 = !box1.includes(item);
return justArr1 || justArr2;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment