Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. Tyler Langan revised this gist Dec 10, 2015. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions bonfire-diff-two-arrays.js
    Original 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);

    });
    }

  2. @invalid-email-address Anonymous created this gist Dec 10, 2015.
    15 changes: 15 additions & 0 deletions bonfire-diff-two-arrays.js
    Original 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]);