-
-
Save JayKan/fbd47091dda43a201c5e90d2f9229ded to your computer and use it in GitHub Desktop.
Remove duplicates from 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) { | |
| var clean = [] | |
| var cleanLen = 0 | |
| var arrLen = arr.length | |
| for (var i = 0; i < arrLen; i++) { | |
| var el = arr[i] | |
| var duplicate = false | |
| for (var j = 0; j < cleanLen; j++) { | |
| if (el !== clean[j]) continue | |
| duplicate = true | |
| break | |
| } | |
| if (duplicate) continue | |
| clean[cleanLen++] = el | |
| } | |
| return clean | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment