|
Hello everybody,
I have two multidimensional arrays and I have to create a third one (for later use) from comparing these two. Here is my example code:
//BEGIN EXTEND SCRIPT/JAVASCRIPT CODE
var myGroups = [["00002","00003","00004","00005"],["00007","00008"],["00009","00010"]];
var myProducts = [["00002"],["00003"],["00007"],["00009"]];
var newGroups = new Array();
function main() {
for(i=0; i<myGroups.length; i++){
var myGroup = myGroups[i];
for(k=0; k<myGroup.length; k++){
for(j=0; j<myProducts.length; j++){
if(myProducts[j]==myGroup[k]){
newGroups.push(new Array(myProducts[j]));
}
}
}
}
alert (newGroups[0]);
}
main();
This way I get a third multidimensional array (newGroups) which contains 1 line arrays, while I want to maintain the grouping structure of the first multidimensional array ([["00002","00003"],["00007"],["00009"]]
Hope you understand the problem..
Any suggestions would be very appreciate
Thanks
|