Created
December 9, 2015 05:10
-
-
Save anonymous/f95c5c6cda83af9ae620 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/fcc0208647c 's solution for Bonfire: Diff Two Arrays
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
// 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