title: JavaScript - Sum of values in same rows and columns
body: <p>I have JavaScript array with numbers 0 and 1 and I need to make a sum of all numbers in same row and column (if I imagine my array in two dimensions). I want to create second array with sums for every single value in first array.<br></p>
  
  <p>2D array visualization for first item (X-Y table of values): <br>
  <b>1</b>,<b>1</b>,<b>1</b>,<b>1</b>,<b>1</b><br>
  <b>1</b>,1,1,1,1<br>
  <b>1</b>,1,1,1,1<br>
  <b>1</b>,1,1,1,1<br>
  <b>1</b>,1,1,1,1<br>
  (Sum: 8 for value at index 0;0 (with value itself excluded))</p>
  
  <p>Real array I have: <br><b>1</b>,<b>1</b>,<b>1</b>,<b>1</b>,<b>1</b>,<b>1</b>,1,1,1,1,<b>1</b>,1,1,1,1,<b>1</b>,1,1,1,1,<b>1</b>,1,1,1,1<br>
  (Sum: 8 for value at index 0)</p>
  
  <p>2D array visualization for second item: <br><b>1</b>,<b>1</b>,<b>1</b>,<b>1</b>,<b>1</b><br>
  1,<b>1</b>,1,1,1<br>
  1,<b>1</b>,1,1,1<br>
  1,<b>1</b>,1,1,1<br>
  1,<b>1</b>,1,1,1<br><br>
  (Sum: 8  for value at index 1;0)<br>
  This way I need to loop through whole array.</p>
  
  <p>2D array visualization for second item with zero separator: <br><b>1</b>,<b>1</b>,<b>1</b>,<b>1</b>,<b>1</b><br>1,<b>1</b>,1,1,1<br>
  1,0,1,1,1<br>
  1,<strike>1</strike>,1,1,1<br>
  1,<strike>1</strike>,1,1,1<br>
  (Sum: 5  for value at index 1;0)<br>
  Values after zero I don't want to count in.</p>
  
  <p>For previous table the result table should be like...<br>
  8,5,8,8,8<br>
  8,5,8,8,8<br>
  4,x,6,6,6<br>
  8,5,8,8,8<br>
  8,5,8,8,8<br></p>
  
  <p>Thank you very much for your help!</p>