Skip to content

Instantly share code, notes, and snippets.

@Sequoya42
Created July 27, 2017 00:58
Show Gist options
  • Save Sequoya42/58b465ae48553c079a787cd8f46de64a to your computer and use it in GitHub Desktop.
Save Sequoya42/58b465ae48553c079a787cd8f46de64a to your computer and use it in GitHub Desktop.
const removeDuplicate = (arr, key, value, nkey = key, nvalue = value) => {
const bail = arr.reduce((a, b) => Object.assign(a, { [b[key]]: b[value] }));
return Object.keys(bail).map(key => ({
[nkey]: key,
[nvalue]: bail[key]
}));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment