title: How can I create a row which sums up the value of each column without knowing the row or column amount?
body: <p>I have included my code below. I am creating a score keeping app and have created the basic score table where user can select player and round amount as well as add player names. I cant work out how to create a row to to sum every round for each player. I have tried several different ways but cant work it out. Any advice would be amazing! Have included code below.</p>
  <pre><code>&lt;hr&gt;
  &lt;body&gt;
  &lt;div class=&quot;game-container&quot;&gt;
    &lt;div class=&quot;row&quot;&gt;
        &lt;div class=&quot;col-md-12&quot;&gt;
            &lt;p&gt;
                &lt;label&gt;Enter number of players&lt;/label&gt;
                &lt;br&gt;
                &lt;input type=&quot;number&quot; class=&quot;form-control&quot; id=&quot;number-input&quot; value=&quot;0&quot; min=&quot;0&quot;&gt;
                &lt;br&gt;
                &lt;button id=&quot;makeTable&quot;&gt;Go&lt;/button&gt;
                &lt;table id=&quot;scoreTable&quot;&gt;
                &lt;/table&gt;
                &lt;button id=&quot;addRound&quot;&gt;Add Round&lt;/button&gt;
                &lt;br&gt;
                &lt;button id=&quot;totalValue&quot;&gt;Sum Values&lt;/button&gt;
            &lt;/p&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;script&gt;
  /*Game page functionaility*/
  
  let numberofRounds = 0;
  // take number-input and make columns of it
  function createColumns(){
    const numberInput = document.getElementById('number-input');
    const numberInputValue = numberInput.value;
    const numberInputValueInt = parseInt(numberInputValue);
    const scoreTable = document.getElementById('scoreTable');
    topRow = document.createElement('tr');
    topRow.setAttribute(&quot;id&quot;, &quot;topRow&quot;);
    scoreTable.appendChild(topRow);
    const players = document.createElement('td');
    players.innerHTML = &quot;Players&quot;;
    topRow.appendChild(players);
    for(let i = 0; i &lt; numberInputValueInt; i++){
      const td = document.createElement('td');
      td.innerHTML = `&lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;score-input&quot;&gt;`;
      topRow.appendChild(td);
    }
    document.getElementById('number-input').style.display = &quot;none&quot;;
    document.getElementById('makeTable').style.display = &quot;none&quot;;
  }
  function addRound(){
    const currentRound = +numberofRounds + 1;
    numberofRounds = currentRound;
    const roundNumber = &quot;round_&quot; + currentRound;
    const numberInput = document.getElementById('number-input');
    const numberInputValue = numberInput.value;
    const numberInputValueInt = parseInt(numberInputValue);
    const scoreTable = document.getElementById('scoreTable');
    topRow = document.createElement('tr');
    topRow.setAttribute(&quot;id&quot;, roundNumber);
    scoreTable.appendChild(topRow);
    const players = document.createElement('td');
    players.innerHTML = currentRound;
    topRow.appendChild(players);
    for(let i = 0; i &lt; numberInputValueInt; i++){
      const td = document.createElement('td');
      td.setAttribute(&quot;id&quot;, &quot;round_&quot;+currentRound+&quot;_player_&quot; + I);
      td.innerHTML = `&lt;input type=&quot;number&quot; class=&quot;form-control&quot; id=&quot;score-input&quot; 
      value=&quot;0&quot;&gt;`;
      topRow.appendChild(td);
    }
  }
  
  function addSumRow() {
    if (!summedItems) {
      const players = document.createElement('td');
    }
  }
  
  // make event listener makeTable
  document.getElementById(&quot;makeTable&quot;).addEventListener(&quot;click&quot;, function() {createColumns();});
  document.getElementById(&quot;addRound&quot;).addEventListener(&quot;click&quot;, function() {addRound();});
  document.getElementById(&quot;totalValue&quot;).addEventListener(&quot;click&quot;, function() {addSumRow();});
  &lt;/script&gt;
  </code></pre>
  <p><img src="https://i.stack.imgur.com/nfPqr.jpg" alt="App screenshot" /></p>