Created
May 25, 2016 16:06
-
-
Save Quaggie/e306777ca3aebd636a55369514bb56b3 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
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