Skip to content

Instantly share code, notes, and snippets.

@Quaggie
Created May 25, 2016 16:06
Show Gist options
  • Save Quaggie/e306777ca3aebd636a55369514bb56b3 to your computer and use it in GitHub Desktop.
Save Quaggie/e306777ca3aebd636a55369514bb56b3 to your computer and use it in GitHub Desktop.
function diffArray(arr1, arr2) {
var arr1Diff = arr1.filter( i => arr2.filter( y => i === y).length === 0);
var arr2Diff = arr2.filter( i => arr1.filter( y => i === y).length === 0);
return arr2Diff.concat(arr1Diff);
}
console.log(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment