title: How can I move specific elements from one array to another?
body: <p>I'm trying to sort out every string, that contains "INIT:" and put it into another array.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>for (j = 0; j &lt; splitCode.length; j++) {
      if (splitCode[j].indexOf('INIT:') &gt; -1) {
          noInit = splitCode[j].replace('INIT:', '');
          cmdList.push('{id:MinecartCommandBlock,Command:"'+noInit+'"}');
          splitCode.splice(j, 1);
      }
  }
  </code></pre>
  
  <p>If it finds <code>INIT:</code> it sets <code>noInit</code> to the string without <code>INIT:</code>. Afterwards, it adds it to the <code>cmdList</code> array and removes the code from the other array. This works, but it only works once. For every following <code>INIT:</code> string it won't work.</p>