I have the following array:
I need to remove the duplicate entries from this array.
The desired outcome:
Here is a code i have tried without any success:
any suggestions or guidance greatly appreciated.
thanks
Code:
myArray.push(name); \\Records that are being pushed: Record 1. name = 10132, category = Computer Record 2. name =10132, category = Windows Server, Computer
myArray.push(category);
Code:
var myArray = [10132,Computer, 10132,Windows Server,Computer,10A8001HUS,Computer,10A8001HUS,Computer];
I need to remove the duplicate entries from this array.
The desired outcome:
Code:
var myArray = [10132,Computer, Windows Server,10A8001HUS,Computer];
Here is a code i have tried without any success:
Code:
for(var i=0;i<myArray.length;i++) {
for(var j=i+1;j<myArray.length;j++) {
if(myArray[i]===myArray[j]) {
myArray.splice(j,1);
}
}
}
gs.log(myArray);
any suggestions or guidance greatly appreciated.
thanks
Last edited: