Code, going through an array in javascript -
'm trying create function continuously loop through array , check if there still elements value. if there no more of these elements, function execute action.
i'm checking '0'. if nothing ='0', want display image. here's have, suggestions?
function partiewin() // on verifie si il y encore des cases avec pour valeur '0' et si non, on fini la partie { var found=false; (i=1; <= hauteur; i++) { (j=1;j <= largeur; j++) { if( decor[i][j]!=0) { window.alert("you win"); found=1; } } } if(!found) { } }
this array
var decor = new array(hauteur); (i=0; <= hauteur; i=i+1) { decor[i] = new array(largeur); }
the array long list of shape :
decor[1][1] = '24'; decor[1][2] = '21'; decor[4][8]='0' ; etc
shouldn't work? i'm not getting alerts or answer whatsoever once '0' technically gone map..
var found = false; for(var = 0; < hauteur.length ; i++){ (var j = 0; j< hauteur[i].length ; j++){ if( hauteur[i][j] == '0'){ found = true; break; } } } if(!found){ console.log("display image code here") }
Comments
Post a Comment