how do i make a loop for a boolean?

hi guys,
how do i make a loop for a boolean and compare it to an array.length?

 var isCorrect : boolean;

 function finish() {
	
	if (dragTgtScript.isCorrect == true){

	   for(var j = 0; j <= dragObjIndex.length; j ++ ) {
		
		if (dragTgtScript.isCorrect[j] == dragObjIndex.length){
		//winGame.animation.Play("move");
		print("win game!");
		}
	   }
   }
				
}

I think you mean, “How do I have multiple guard conditions”.

You can do something like this:

var isCorrect : boolean = false;
function finish() {
   for (var j = 0; j < 10 && !isCorrect; ++j) {
     //do some stuff
   }
}

or, if you want to break out of a loop, you can include “break”

e.g.

for (int i = 0; i < 10; ++i) {
   if (i == 3) break;
   else Debug.Log("" + i);
}

Will produce the following output:

0
1
2

Note: only up to “2” because once “i == 3” is true, we “break” the loop.

i do a drag and drop objects. and when the objects snap: isCorrect = true.
and the dragObjIndex is array. so i wanna make if all objects snapped to its position. you win the game.
this is the snap

function snap (objToSnap: GameObject, posToSnap: Vector3) {
	
	objToSnap.transform.position.x = posToSnap.x;
	objToSnap.transform.position.y = posToSnap.y;
	canSnap = true;
	isCorrect = true;
	dragObjScript.isMatch = true;
	//objToSnap.name = "Snap";
	print("Snap");
}