Created
December 10, 2015 14:50
-
-
Save anonymous/eb976dba905b1c027cbc to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/tylerl-uxai 's solution for Bonfire: Diff Two Arrays
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
// Bonfire: Diff Two Arrays | |
// Author: @tylerl-uxai | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-diff-two-arrays | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function diff(arr1, arr2) { | |
// Same, same; but different. | |
return arr1.concat(arr2).filter(function(val){ | |
return !(arr1.indexOf(val)>=0 && arr2.indexOf(val) >=0); | |
}); | |
} | |
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