Novi: 4D array

Beitrag lesen

Hallo,

var cells=[[[[]]]];

Das bringt glaube ich nicht den gewünschten Effekt, da du immer nur dem Element mit dem Index 0 ein neuer Array zuweist.

cells[temp1][temp2][temp3].push([coords,up[i].split(" ")]);

Ungetestet:

 if(!typeof cells[temp1] == object) {  
cells[temp1] = [];  
}  
if(!typeof cells[temp1][temp2] == object) {  
cells[temp1][temp2] = [];  
}  
if(!typeof cells[temp1][temp2][temp3] == object) {  
cells[temp1][temp2][temp3] = [];  
}  
cells[temp1][temp2][temp3].push([coords,up[i].split(" ")]);

Oder so:

 if(!cells[temp1]) {  
cells[temp1] = [];  
}  
if(!cells[temp1][temp2]) {  
cells[temp1][temp2] = [];  
}  
if(!cells[temp1][temp2][temp3]) {  
cells[temp1][temp2][temp3] = [];  
}  
cells[temp1][temp2][temp3].push([coords,up[i].split(" ")]);

Viele Grüße Novi

--
"(...) deshalb mag ich Binärtechnik. Da gibt es nur drei Zustände: High, Low und Kaputt." (Wau Holland)