Skip to content

Instantly share code, notes, and snippets.

@brianfernalld
Created March 11, 2013 17:56
Show Gist options
  • Save brianfernalld/5136208 to your computer and use it in GitHub Desktop.
Save brianfernalld/5136208 to your computer and use it in GitHub Desktop.
Remove duplicates from array
/**
* Remove duplicates from array
* @param {Object} num
*/
function removeDup(num){
cleaned = [];
original = num;
for(i=0;i<original.length;i++){
if (cleaned.indexOf(original[i]) === -1){
cleaned.push(original[i]);
}
}
console.log('Remove duplicates: ' + cleaned);
}
num=[7, 1,2,7,7,7,3,4,4,5,5,6,2,1,1,2,3];
removeDup(num);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment