I would like to simplify a code snippet where I have one main loop in which I put 2 if statements. The first if statement is about a test "`if (test1 or test2)`" and the second one is a test "`if (test1 and test2)`". 

Curently, to differentiate them, I have to put at a higher level (but still in the main loop) another "if" (test on `diagExpression boolean`, see below); here's the code :

```
// Main loop 
  while (Hit.arrayCurrent[Hit.coordCurrent[0]+k][Hit.coordCurrent[1]+l] == Hit.currentPlayer[1]) 
  {   
   if (diagExpression)
     {   
      if ((a > b) || (b > c))
        return;
      else if (d)
       {   
        //do stuff1
       }   
     }   
  else
    {   
     if ((a > b) && (b > c))
        return;
     else if (d)
       {   
        //do stuff1
       }   
     }   
  }

```

I don't know how to do for simplifying this code snippet and avoiding to use the `stuff1` 2 times.

If anyone could see a solution.

**UPDATE :**

`diagExpression` is computed before the main loop : 

```
// Boolean for 2 versions
  var diagExpression = false;

  if (Hit.direction == 'rightbottom')
    { 
      diagExpression = true;
      shift_x = 1;
      shift_y = 1;
      factor_x = 1;
      factor_y = 1;
      limit_x = 7;
      limit_y = 7;
    }
 else if (Hit.direction == 'left')
    {
      shift_x = -1;
      shift_y = 0;
      factor_x = -1;
      factor_y = 1;
      limit_x = 0;
      limit_y = -1;
    }

...

// Main loop 
  while (Hit.arrayCurrent[Hit.coordCurrent[0]+k][Hit.coordCurrent[1]+l] == Hit.currentPlayer[1])

```

I use different directions values into my code and this boolean is true if I have diagonal directions and false for vertical/horizontal directions.