Forked from anonymous/bonfire-diff-two-arrays.js
Created
December 10, 2015 14:50
Revisions
-
Tyler Langan revised this gist
Dec 10, 2015 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,13 +2,12 @@ // Author: @tylerl-uxai // Challenge: http://www.freecodecamp.com/challenges/bonfire-diff-two-arrays // Learn to Code at Free Code Camp (www.freecodecamp.com) // with the help of http://wulkan.me/bonfire-diff-two-arrays/ and https://github.com/pfilippi24 function diff(arr1, arr2) { // Same, same; but different. return arr1.concat(arr2).filter(function(val){ return !(arr1.indexOf(val)>=0 && arr2.indexOf(val) >=0); }); } -
There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ // 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]);