title: How to separate array with 5 numbers
body: <p>I have an array with 5 numbers from 1 to 6. I can have arrays with different configurations from [1,1,1,1,1] trough [1,2,3,4,5] to for example [1,2,2,2,6]. 
  The array is sorted. For example:</p>
  
  <pre><code>var table = [1,1,1,1,1];
  </code></pre>
  
  <p>or</p>
  
  <p><code>var table = [1,2,2,4,5];</code></p>
  
  <p>or</p>
  
  <p><code>var table = [1,2,2,2,6];</code></p>
  
  <p>I have to divide it on this conditions:
  if there are exactly three the same numbers I have to group them together and leave another numbers as separate arrays with one element so it would be:</p>
  
  <pre><code>var table = [[1,1,1],[1],[1]];
  </code></pre>
  
  <p>or</p>
  
  <p><code>var table =  [[1],[2,2,2],[6]];</code></p>
  
  <p>or if there are not 3 the same numbers it should look like:</p>
  
  <p><code>var table = [[1],[2],[2],[4],[5]];</code></p>
  
  <p>I tried with iterations etc but apparently it's beyond my imagination. </p>
  
  <p>I tried with condition like this:</p>
  
  <pre><code>    for (var i=0;i&lt;table.length;i++){
        if(table[i] == table[i+1] &amp;&amp; table[i] == table[i+2]){
  // sorting here 
  }}
  </code></pre>
  
  <p>But it won't work for array with 5 the same numbers like: </p>
  
  <pre><code> var table = [1,1,1,1,1];
  </code></pre>