I want to do a grid calculation of numbers the grid is 30x30 so i came up with the idea of having 30 arrays with 30 numbers in it. and now i'm looking for a way to go from array1 to array2 with a simple increment instead retyping it 30 times
var array1 = ['blue','red'];
var array2 = ['magenta','yellow'];
var curarray = 1;
console.log(array+curarray)
//something like the above (the example obviously doesn't work)
Just create an array that holds all the arrays
var arr = [
['blue','red'],
['magenta','yellow']
];
Then you can access the data via its index (an array has an index automatically)
var curarray = 0;
console.log(arr[curarray]); // ['blue','red']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.