You have the following arrays.
Array0 = ["Apple", "Banana", "Chicken"];
Array1 = [5, 7, 8];
Array2 = ["High", "Low", "Low"];
You want to convert above arrays to the following array.
[["Apple",5,"High"],["Banana",7,"Low"],["Chicken",8,"Low"]]
From your sample array, the array length of each array is the same.
If my understanding is correct, how about this modification? Please think of this as just one of several answers.
Modified script 1:
var Array0 = ["Apple", "Banana", "Chicken"];
var Array1 = [5, 7, 8];
var Array2 = ["High", "Low", "Low"];
var arrays = [Array0, Array1, Array2]; // Please prepare this.
var res = [];
for (var i = 0; i < arrays[0].length; i++) {
var temp = [];
for (var j = 0; j < arrays.length; j++) {
var ar = arrays[j];
temp.push(ar[i]);
}
res.push(temp);
}
Logger.log(res)
Modified script 2:
var Array0 = ["Apple", "Banana", "Chicken"];
var Array1 = [5, 7, 8];
var Array2 = ["High", "Low", "Low"];
var numberOfArrays = 3; // Please prepare this. In your case, it's 3.
var res = [];
for (var i = 0; i < Array0.length; i++) {
var temp = [];
for (var j = 0; j < numberOfArrays; j++) {
var ar = eval("Array" + j);
temp.push(ar[i]);
}
res.push(temp);
}
Logger.log(res)
Note:
- Please select one of above scripts for your situation.
If I misunderstood your question and this was not the result you want, I apologize.