# Logical Operator & amp&semi; & Amp&semi; In a statement

I’m iterating over an array and want to do the following:

```for (
var i = 0;
i < array.length && !(array[i][1] == 0 && array[i][2] == 'foo');
i++)
{```

So basically I’m saying “if i is less than the array’s length AND it’s not true that array[i]1 is 0 AND array[i][2] is ‘foo'” then do a bunch of stuff.

But it doesn’t work. It always evaluates to false when array[i][2] is ‘foo’, even if array[i][1] is not equal to 0.

Strangely though if I make the for statement like this:

`for (var i = 0; i < array.length; i++) {`

… and then put this right at the beginning of the loop:

`if (array[i][1] == 0 && array[i][2] == 'foo') continue;`

… it works. So I must be messing up the syntax somehow when I’m trying to say “IF TRUE AND !(CONDITION 1 && CONDITION 2)” but I’m not sure what I’m doing wrong. Where’s my error?

If you put the test `!(array[i][1] == 0 && array[i][2] == 'foo')`
in the loop control expression, then when that fails, the loop stops
. It doesn’t skip that iteration and continue to the next one any more than it would if `i < array.length`
were false. It just stops.

If you want it to continue to the next iteration, you need to put the test in the loop body and use `continue`
.

|