title: .split(",") every 4th item only?
body: <p>I started with a string:</p>
  
  <pre><code>hidden = "a,b,c,d,e,f,g,h";
  </code></pre>
  
  <p>I then split(",") the string into something I can try to work with:</p>
  
  <pre><code>array = hidden.split(",");
  </code></pre>
  
  <p>If I console.log out, the result is:</p>
  
  <pre><code>["a", "b", "c", "d", "e", "f", "g", "h"]
  </code></pre>
  
  <p>What I would eventually like to end up with (using JS only) is:</p>
  
  <pre><code>["a,b,c,d","e,f,g,h"];
  </code></pre>
  
  <p>or</p>
  
  <pre><code>[["a,b,c,d"],["e,f,g,h"]];
  </code></pre>
  
  <p>Thanks!</p>
  
  <p>EDIT to show that I am actually trying to figure this out (don't mind the formatting):</p>
  
  <pre><code>if (currentPage === "view-bills.php")
  {
  var str = "";
  hidden = document.getElementById("billItems");
  array = hidden.value.split(",");
  for (var i=0;i&lt;array.length;i++)
  {
  str += "&lt;option&gt;"+ array[i] +"&lt;/option&gt;";
  }
  var itemsAmt = document.getElementById("items").value;
  document.getElementById("displayItems").innerHTML = "&lt;optgroup label='"+ itemsAmt +" items'&gt;" + str + "&lt;/optgroup&gt;";
  }
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>The problem has been solved, however, I would like to show you the outcome of my project (accessing classes instead of id's this time):</p>
  
  <p><a href="https://i.imgur.com/umjhGPP.png" rel="nofollow noreferrer">http://i.imgur.com/umjhGPP.png</a>
  <img src="https://i.stack.imgur.com/VJuDU.png" alt="ProjectResults"></p>
  
  <p>Once again, don't mind my formatting, I have trouble pasting things in here:</p>
  
  <pre><code>if (currentPage === "view-bills.php")
  {
  // Add items to select box
  hidden = document.getElementsByClassName("billItems");
  for (var n=0;n&lt;hidden.length;n++)
  {
  array = hidden[n].value.split(",");
  groups = [];
  for(var i=0;i&lt;array.length;i+=5)
  {
  groups.push(array.slice(i,i+5).join(','))
  }
  var str = "";
  for (var j=0;j&lt;groups.length;j++)
  {
  str += "&lt;option&gt;"+ groups[j] +"&lt;/option&gt;";
  }
  var itemsAmt = document.getElementsByClassName("items")[n].value;
  document.getElementsByClassName("displayItems")[n].innerHTML = "&lt;optgroup label='"+ itemsAmt +" items'&gt;" + str + "&lt;/optgroup&gt;";
  }
  }
  </code></pre>