Skip to content

Instantly share code, notes, and snippets.

@simonschwartz
Last active February 4, 2018 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonschwartz/a17151d6d7fb08cbfe08cd842b1373ca to your computer and use it in GitHub Desktop.
Save simonschwartz/a17151d6d7fb08cbfe08cd842b1373ca to your computer and use it in GitHub Desktop.
// 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