Created
January 20, 2021 18:15
-
-
Save Shariar-Hasan/18e5281930260965f3ded5fa1bab6f43 to your computer and use it in GitHub Desktop.
To remove duplicate items from an array in javascript
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
var numbers = [1,2,5,3,7,5,6,8,9,9,0,3,4,5,6,5,5,4,3,3,4,4]; | |
function duplicateRemover(numbers) | |
{ | |
var uniqueArray = [] | |
for(var i = 0; i< numbers.length ; i++) | |
{ | |
if(uniqueArray.indexOf(numbers[i]) == -1) | |
{ | |
uniqueArray.push(numbers[i]); | |
} | |
} | |
return uniqueArray; | |
} | |
console.log(duplicateRemover(numbers)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment