Last active
May 9, 2020 10:57
-
-
Save AvocadoVenom/5681bf49f9fd0fa5c081f3ace47c4d83 to your computer and use it in GitHub Desktop.
JS function to remove duplicates in array.
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
| function removeDuplicates(arr) { | |
| return arr.reduce((acc, cur) => { | |
| if(acc.indexOf(cur) === -1) acc.push(cur); | |
| return acc; | |
| }, []); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment