Skip to content

Instantly share code, notes, and snippets.

@sebastianherman
Created January 9, 2021 14:28
Show Gist options
  • Save sebastianherman/15b3f0adb7be3fc0c879fdb182dd2a41 to your computer and use it in GitHub Desktop.
Save sebastianherman/15b3f0adb7be3fc0c879fdb182dd2a41 to your computer and use it in GitHub Desktop.
Intermediate Algorithm Scripting: Diff Two Arrays - freeCodeCamp solution
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