javascript - Update Matrix According to Array elements -
i know title of questions seems bit odd answer i'm looking title. lets have array of arrays , want update according arrays elements. example;
array of arrays;
var arrayofarrays = [ [ [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], ], [ [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false], ] ]
and have array
var elementarray = ["0-7-3","2-10-0","2-11-0","2-12-1"]
is there shortcut update array of arrays according elements in second array update 7th array of 0th array's 3rd column true. appreciated.
you can split out index , use on large array.
var elementarray = ["0-7-3","2-10-0","2-11-0","2-12-1"]; for(var = 0; < elementarray.length; i++){ var idx = elementarray[i].split('-'); arrayofarrays[idx[0]][idx[1]][idx[2]] = true; }
Comments
Post a Comment