# \[AS2 F8\] shortening an 'if' statement with 'for'

**URL:** <https://forum.kirupa.com/t/as2-f8-shortening-an-if-statement-with-for/317269>\
**Category:** flash\
**Created:** [December 15, 2010, 12:05pm UTC](https://forum.kirupa.com/t/as2-f8-shortening-an-if-statement-with-for/317269 "2010-12-15T12:05:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![540media](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/540media/32/2543_2.png) [@540media](https://forum.kirupa.com/u/540media)\
**Post date:** [December 15, 2010, 12:05pm UTC](https://forum.kirupa.com/t/as2-f8-shortening-an-if-statement-with-for/317269/1 "2010-12-15T12:05:26Z")

</div>

Hi I’m having a problem trying to shorten an if statement using a for loop

at the minute I have an array which holds 6 elements, each of these elements change depending on a series of 6 buttons pressed on stage

I have a ‘if’ statement that checks if certain elements in the array have change, there are 4 different combinations that I want to trace as correct. I can do this fine, but I will need to develop this to be able to accept 90+ different combinations and I dont want to write out a massive if statement listing all the possiblites, can anyone help me write the current ‘if’ statment I have it to neater code that I can then expend in the future

```auto

row0 = [0,0,0,0,0,0,0];

onEnterFrame = function(){
    if(row0[0]==1 && row0[1]==1 && row0[2]==1 && row0[3]==1 ||
       row0[1]==1 && row0[2]==1 && row0[3]==1 && row0[4]==1 ||
       row0[2]==1 && row0[3]==1 && row0[4]==1 && row0[5]==1 ||
       row0[3]==1 && row0[4]==1 && row0[5]==1 && row0[6]==1){
        player1 = "winner"
    } else {
        player1 = "loser"
    }
}

```
