ttomasko
Programmer
- Aug 6, 2008
- 28
I have an array of objects, some of which are duplicates. I need to pare this down so that there are only unique objects.
I can't show these objects here because they are in the InDesign object model. The best I can do is to make an array of arrays, two of which have equal last elements.
The script here does not work. It returns an array of all the elements of all the arrays. Can someone point me in a direction that will solve this?
Thanks,
Tom
I can't show these objects here because they are in the InDesign object model. The best I can do is to make an array of arrays, two of which have equal last elements.
The script here does not work. It returns an array of all the elements of all the arrays. Can someone point me in a direction that will solve this?
Thanks,
Tom
Code:
var a = [[1,2,3],[4,5,6],[7,8,3],[7,8,9]];
var b = new Array;
for(var x = 0; x<a.length; x++){
for(var y = 0; y<a.length; y++){
if(a[x][2] != a[y][2]){
b = b.concat(a[y]);
}//end if
}//end for y
}//end for x
b;
//what I want: b = [[1,2,3],[4,5,6],[7,8,9]];