title: Remove array item using for...of loop
body: <p>I'm trying to edit an array and remove elements that do not meet a certain condition. If I use a <code>reverse for loop</code> combined with <code>.splice(index,n)</code>, the code works just fine. I'm stuck at implementing the same using the ES6 <code>for...of</code> loop</p>
  
  <pre><code>let array=[1,2,3];
  //reverse for loop
  for(var i=array.length - 1; i&gt;=0; i--) {
    if(array[i]&gt;=2) {
      /*Collect element before deleting it.*/
      array.splice(i,1);
    }
  } 
  console.log(array);
  // returns [1]
  </code></pre>
  
  <p>Using for..of</p>
  
  <pre><code>let array=[1,2,3];
  for(let entry of array) {
      if(entry&gt;=2) {
          let index = array.indexOf(entry);
  
          /*The array is being re-indexed when I apply 
          .splice() - the loop will skip over an index
          when one element of array is removed*/
  
          array.splice(index, 1);
      }
  } 
  console.log(array);
  //returns [1,3]
  </code></pre>
  
  <p>Is there a way to achieve this functionality using a <code>for...of</code> loop or do I have to stick to the <code>reverse for loop</code></p>
  
  <p><strong>Update</strong> <br>
  I need to collect the entries that don't meet the elements removed by either the <code>filter()</code> or <code>reverse for loop</code> functions to a secondary array.</p>