JavaScript: Split array into groups (array of arrays) based on equal values
<p>I'm trying to do this exercise:</p>

<blockquote>
  <p>The challenge is to implement a function which adds all together all
  the consecutive numbers in an array and pushes them into a new array.
  example: sumConsecutives([1,1,2,1,1,1,1,2,1,1,1]);
      <code>// -&gt; [2,2,4,2,3]</code></p>
</blockquote>

<p>My idea is to split the array into an array of arrays. So for the above example: <code>[[1,1],[2],[1,1,1,1],[2],[1,1,1]]</code> then go through and <code>reduce</code> them.</p>

<p>I've tried with a <code>while</code> loop and <code>push</code> into a temp variable which then gets pushed if the next number is not the same, to no avail.</p>

<p>Any ideas on how to achieve this?</p>