Skip to content

Instantly share code, notes, and snippets.

Created December 9, 2015 05:10
Show Gist options
  • Save anonymous/f95c5c6cda83af9ae620 to your computer and use it in GitHub Desktop.
Save anonymous/f95c5c6cda83af9ae620 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/fcc0208647c 's solution for Bonfire: Diff Two Arrays
// Bonfire: Diff Two Arrays
// Author: @fcc0208647c
// Challenge: http://www.freecodecamp.com/challenges/bonfire-diff-two-arrays
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function diff(arr1, arr2) {
arr3 = arr1.concat(arr2);
final = arr3.filter(function(val, index, arr){
console.log(arr3.indexOf(val),arr3.lastIndexOf(val),val);
return arr3.indexOf(val) === arr3.lastIndexOf(val);
});
return final;
}
diff([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