Let's say i have a for loop and i want to initialize multiple arrays in that loop. Can it be achieved like this?:
for (var i = 0; i < 5; i++){
var array+i = [];
}
So that the arrays that will be created are array0,array1,array2,array3,array4?
Any help would be much appreciated :)
You can use a multi dimensional array to tackle this problem:
for(var i=0;i<5;i++){
var array[i]=[];
}
which will result in:
array[0] = []
array[1] = []
array[2] = []
array[3] = []
array[4] = []
hope that helps :)
You can achieve something like that using
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With