title: Loop to remove an element in array with multiple occurrences
body: <p>I want to remove an element in an array with multiple occurrences with a function.</p>
  
  <pre><code>var array=["hello","hello","world",1,"world"];
  
  function removeItem(item){
      for(i in array){
          if(array[i]==item) array.splice(i,1);
      }
  }
  </code></pre>
  
  
  
  <pre><code>removeItem("world");
  //Return hello,hello,1
  </code></pre>
  
  
  
  <pre><code>removeItem("hello");
  //Return hello,world,1,world
  </code></pre>
  
  <p>This loop doesn't remove the element when it repeats twice in sequence, only removes one  of them.</p>
  
  <p>Why?</p>