Javascript For loop in multidimensional javascript array -


can give me sample/example of javascript multidimensional array of inputs? hope because i'm still new javascript.

like this:

 var cubes =   [[1, 2, 3],[4, 5, 6],[7, 8, 9]];  output : [1,4,7],          [1,4,8],          [1,4,9],          [1,5,7],          [1,5,8],          [1,5,9],          [1,6,7],          [1,6,8],          [1,6,8],         .........          .........          [3,6,7],          [3,6,8],          [3,6,9] 

thanks

this code should work:

var cubes = [[1, 2, 3],[4, 5, 6],[7, 8, 9]];  for(var i=0; i<cubes[0].length; ++i) for(var j=0; j<cubes[1].length; ++j) for(var k=0; k<cubes[2].length; ++k) {     alert([cubes[0][i],cubes[1][j],cubes[2][k]]); } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -