title: Javascript, all possible sums of an array members (up to 4)
body: <p>I am unable to figure out how to write a function that will calculate all possible sums of of the elements of an array, with a max of 4 elements per addition.</p>
  
  <p>Given</p>
  
  <pre><code>x = [1, 32, 921, 9213, 97, 23, 97, 81, 965, 82, 965, 823]
  </code></pre>
  
  <p>I need to go from <code>(1+32) ~ (965+823)</code> to <code>(1+32+921+9213) ~ (965+82+965+823)</code>, calculating all the possible sums.</p>
  
  <p>The output should be an array like this:</p>
  
  <p>{33: [1, 32], 922: [1, 921], .... 2835: [965, 82, 965, 823]}</p>
  
  <p>filled by all the possible sums.</p>
  
  <p>It's not for homework, and what I was looking for is explained down there by Travis J: it was about permutations. 
  Thanks everybody, I hope this could be useful also to someone else.</p>