title: javascript odd and even separation in an array of numbers
body: <p>i wants to separate an array with two groups (odd and even) sequentially. but when i try this:</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 arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
      
      for (var i = 0; i &lt; arr.length; i++) {
        if (arr[i]%2 == 0) {
          arr.push(arr.splice(i, 1)[0]);
        }
      }
      
      console.log(arr);</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>console.log(arr); 
  // [1, 3, 5, 7, 9, 4, 8, 6, 2]
  </code></pre>
  
  <p>why 4,8,6,2 instead of 2,4,6,8?</p>