Ronald McDonald Ronald McDonald - 8 months ago 74
Javascript Question

Kind of increment on arrays in js

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;
//something like the above (the example obviously doesn't work)


Just create an array that holds all the arrays

var arr = [

Then you can access the data via its index (an array has an index automatically)

var curarray = 0;
console.log(arr[curarray]); // ['blue','red']