Created
January 9, 2021 14:28
-
-
Save sebastianherman/15b3f0adb7be3fc0c879fdb182dd2a41 to your computer and use it in GitHub Desktop.
Intermediate Algorithm Scripting: Diff Two Arrays - freeCodeCamp solution
This file contains hidden or 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) { | |
let newArr1 = arr1.filter(val => { | |
return arr2.indexOf(val) == -1; | |
}) | |
let newArr2 = arr2.filter(val => { | |
return arr1.indexOf(val) == -1; | |
}) | |
return newArr1.concat(newArr2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment