-
-
Save emanuel-sanabria-developer/cf1fe4a50efc2822e3df7b1bb052d90e to your computer and use it in GitHub Desktop.
simple uniq array implementation
This file contains 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
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