title: An element of an array doesn't pass a test
body: <p>I am writing a function that loops through an array and tests each element for a condition. If it is false, the element is dropped. If it is true, the function returns the rest of the array.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>function dropElements(arr, func) {
      // Loop through the array
      for(var i = 0; i &lt; arr.length; i++){
        // if the current element passes the test, return the rest of the array
        if (func(arr[i])){
          return arr;
        // otherwise remove the element
        } else {
          arr.shift();  
        }
      }
      // if no conditions were met, return empty array
      return arr;
  }
  </code></pre>
  
  <p>When the loop reaches i = 1, we have arr[1] = 2. </p>
  
  <p>Since 2 is not >= 3, I do not understand why it is not dropped.</p>
  
  <p>So, why does the following call</p>
  
  <pre><code>dropElements([1,2,3,4], function(n) {return n &gt;= 3; });
  </code></pre>
  
  <p>return [2,3,4] instead of [3,4] ? </p>
  
  <p>Thanks.</p>