Created
September 24, 2021 03:53
-
-
Save aaei924/f2105e7ba184702f3dc2e86f6392d03d to your computer and use it in GitHub Desktop.
Remove Duplicate Array Elements
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
const removeDuplicates = (inArray) => { | |
var arr = inArray.concat() | |
for(var i=0; i<arr.length; ++i) { | |
for(var j=i+1; j<arr.length; ++j) { | |
if(arr[i] === arr[j]) { | |
arr.splice(j, 1) | |
} | |
} | |
} | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment