Last active
February 4, 2018 23:30
-
-
Save simonschwartz/a17151d6d7fb08cbfe08cd842b1373ca to your computer and use it in GitHub Desktop.
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
// Compare two arrays(primary and secondary) and return all array items that are unique to the primary array | |
const getDiff = (primaryArray, secondaryArray) => { | |
return primaryArray.filter(item => secondaryArray.indexOf(item) === -1); | |
}; | |
// getDiff([1, 2, 3, 5], [1, 3, 4]) | |
// => [2, 5] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment