title: splice() inside a for loop, what is the solution?
body: <p>I'm trying to remove repetitions from this array called "bigArray" while keeping the three first positions of the array intact (even if they repeat).</p>
  
  <p>My issue is that the splice() inside the for loop is not working properly, since every time it splices, the for loop skips the next position of the array (since that position is then one position lower in the array).</p>
  
  <p><strong>How do I get my function to return [0,0,0,3,2] ?</strong></p>
  
  <p>Thank you</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var bigArray = [0,0,0,3,2,2,3,3,2];
  
  function call() { 
  
    
    for (let i=3; i &lt; (bigArray.length); i++) {
      if (bigArray.indexOf(bigArray[i]) !== i) {
            bigArray.splice(i,1);
      
      }
  
      }
      
      console.log(bigArray);
      return bigArray; 
  }
      
  call();</code></pre>
  </div>
  </div>
  </p>