ttomasko
Programmer
- Aug 6, 2008
- 28
Hello,
I have a script that has three levels of for statements. Right now the end result is that I get returned the last values of each array. What I wish however is to preserve the values of the first and second iterations.
This returns 3bz,. However, what I want is:
1ax, 1ay, 1az
1bx, 1by, 1bz
2ax, 2ay, 2az, etc.
How can I construct this to get that result?
Thanks,
Tom
I have a script that has three levels of for statements. Right now the end result is that I get returned the last values of each array. What I wish however is to preserve the values of the first and second iterations.
Code:
var a = [1,2,3];
var b = ["a","b"];
var c = ["x","y","z"];
for(var i = 0; a.length> i; i++){
var aValue = a[i];
for(var j = 0; b.length> j; j++){
var bValue = b[j];
for(var k = 0; c.length> k; k++){
var cValue = c[k];
}//end for k
}//end for j
}//end for i
alert(aValue+bValue+cValue+", ");
1ax, 1ay, 1az
1bx, 1by, 1bz
2ax, 2ay, 2az, etc.
How can I construct this to get that result?
Thanks,
Tom