Created
August 6, 2018 03:36
-
-
Save kbk0125/c3ed8c3aea23414a8f66822e3db2a0f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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