Ronald McDonald Ronald McDonald - 1 year ago 117
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)

Answer Source

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']
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download