Skip to content

Instantly share code, notes, and snippets.

@linkin-park

linkin-park/FCC Secret

Created September 19, 2017 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linkin-park/521b97a68288fc1f6a44ca430b798ff5 to your computer and use it in GitHub Desktop.
Save linkin-park/521b97a68288fc1f6a44ca430b798ff5 to your computer and use it in GitHub Desktop.
FCC
https://www.freecodecamp.org/challenges/diff-two-arrays
function diffArray(arr1, arr2) {
return arr2.filter(x=>arr1.indexOf(x) == -1)
.reduce((tot,curr)=>{tot.push(curr); return tot;}
,arr1.filter(x=>arr2.indexOf(x) == -1));
}
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