title: While loop with if statements doesn't work
body: <p>I'm solving some coderbyte.com challenges and I run into some problems. This is the task:</p>
  <blockquote>
  <p>Using the JavaScript language, have the function <code>ArithGeo(arr)</code> take the array of numbers stored in <code>arr</code> and return the string &quot;Arithmetic&quot; if the sequence follows an arithmetic pattern or return &quot;Geometric&quot; if it follows a geometric pattern. If the sequence doesn't follow either pattern return -1.</p>
  <p>An arithmetic sequence is one where the difference between each of the numbers is consistent, where as in a geometric sequence, each term after the first is multiplied by some constant or common ratio. Arithmetic example: [2, 4, 6, 8] and Geometric example: [2, 6, 18, 54].</p>
  <p>Negative numbers may be entered as parameters, 0 will not be entered, and no array will contain all the same elements.</p>
  </blockquote>
  <pre><code>function ArithGeo(arr) { 
        var x = 0;
        var s = 0;
        var allObjects = [];
        for(var i=0; i&lt;arr.length;i++) {
          while(x&lt;arr.length-1) {
            var diff = arr[x+1]-arr[x];
            allObjects.push(diff);
            x++;
          }
          
         while(s&lt;allObjects.length) {
            console.log(allObjects.length);
           
            if(allObjects[s]===allObjects[s+1]) {
              console.log('entered if');
              return &quot;Arithmetic&quot;;
              s++;
              
            }
            else if(allObjects[s+1]%allObjects[s]===0) {
              return &quot;Geometric&quot;;
              s++;
            }
            else {
              return &quot;-1&quot;;
              s++;
            }
           }
          
          
         
        }
               
      }
         
      // keep this function call here 
      // to see how to enter arguments in JavaScript scroll down
      ArithGeo([1,2,3,100]);    
  </code></pre>
  <p>It enters into first if statement only once, and it should enter 3 times, for every element in <code>allObjects</code> array. Can you tell me why this is?</p>