Say that I have a for loop with index i, and I want to have a variable with a name that ends with the character(s) of the index number. Therefore, each time for loops, it will create a variable with a unique name. I want this variable to be a global variable, too. And then, I would want to use each of those variables later by calling var name(i)
name of index. It would be okay if they were called some other way, too.
It could maybe be done with an array, but with this case, I end up with an array of arrays again, and I need a single array. I need to start with an array of arrays, too.
var arrays = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
var array = [];
for(i = 0; i < arrays.length; i ++)
array[i] = arrays[i];
And I cannot simply use the reduce function because I want each of the arrays in my array of arrays to be a separate array.
var arrays = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
arrays.reduce(function(a, b){
return a.concat(b);
}, []);
Note that the input array of arrays will be different each time the program runs and sometimes be jagged.