programming-examples/js/Array/Write a JavaScript program to remove duplicate items from an array (ignore case sensitivity)..js
2019-11-15 12:59:38 +01:00

18 lines
373 B
JavaScript

function removeDuplicates(num) {
var x,
len=num.length,
out=[],
obj={};
for (x=0; x<len; x++) {
obj[num[x]]=0;
}
for (x in obj) {
out.push(x);
}
return out;
}
var Mynum = [1, 2, 2, 4, 5, 4, 7, 8, 7, 3, 6];
result = removeDuplicates(Mynum);
console.log(Mynum);
console.log(result);