Skip to content

Instantly share code, notes, and snippets.

@emanuel-sanabria-developer
Created June 20, 2019 10:46
Show Gist options
  • Save emanuel-sanabria-developer/cf1fe4a50efc2822e3df7b1bb052d90e to your computer and use it in GitHub Desktop.
Save emanuel-sanabria-developer/cf1fe4a50efc2822e3df7b1bb052d90e to your computer and use it in GitHub Desktop.
simple uniq array implementation
export const unique = array => {
if (!array.length || array.length === 1) {
return array;
}
return array.reduce(
(uniqArray, current) =>
!uniqArray.includes(current) ? uniqArray.concat(current) : uniqArray,
[]
);
};
export default unique;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment