Skip to content

Instantly share code, notes, and snippets.

@emmabostian
Created March 19, 2020 14:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save emmabostian/870a51a62fb140928cc6a28473f2eedf to your computer and use it in GitHub Desktop.
Save emmabostian/870a51a62fb140928cc6a28473f2eedf to your computer and use it in GitHub Desktop.
function diffArray(arr1, arr2) {
let arr1UniqueItems = arr1.filter(item => arr2.indexOf(item) < 0);
let arr2UniqueItems = arr2.filter(item => arr1.indexOf(item) < 0);
return [...arr1UniqueItems, ...arr2UniqueItems];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment