title: Convert calculator into 2D array
body: <p>I am attempting to convert my current calculator into a <code>two-dimentional array</code>using Javascript. Also, I want the calculator to be able to calculate the amount of days selected in two different calenders using the <code>&lt;input type"date"</code></p>
  
  <p>Current code:
      </p>
  
  <pre><code>  &lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Demo&lt;/title&gt;
      &lt;style type="text/css"&gt;
        table,
        td,
        th {
          border: 1px solid black;
        }
  
        table {
          border-collapse: collapse;
        }
  
        .selected {
          background-color: lightblue;
        }
  
      &lt;/style&gt;
    &lt;/head&gt;
  
    &lt;body&gt;
      &lt;table&gt;
        &lt;tr&gt;
          &lt;th bgcolor="b8cce4"&gt;Destinasjon&lt;/td&gt;
            &lt;th&gt;Rental Gear&lt;/td&gt;
              &lt;th&gt;Pre-heated hut&lt;/td&gt;
                &lt;th&gt;Extra firewood&lt;/td&gt;
                  &lt;th&gt;Ski-pass&lt;/td&gt;
                    &lt;th&gt;Internet connection&lt;/td&gt;
                      &lt;th&gt;Final price&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td bgcolor="b8cce4"&gt;&lt;b&gt;Trysil&lt;/b&gt;&lt;/td&gt;
          &lt;td&gt;100&lt;/td&gt;
          &lt;td&gt;50&lt;/td&gt;
          &lt;td&gt;20&lt;/td&gt;
          &lt;td&gt;150&lt;/td&gt;
          &lt;td&gt;25&lt;/td&gt;
          &lt;td&gt;$&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td bgcolor="b8cce4"&gt;&lt;b&gt;Kongsberg&lt;/b&gt;&lt;/td&gt;
          &lt;td&gt;75&lt;/td&gt;
          &lt;td&gt;50&lt;/td&gt;
          &lt;td&gt;30&lt;/td&gt;
          &lt;td&gt;125&lt;/td&gt;
          &lt;td&gt;20&lt;/td&gt;
          &lt;td&gt;$&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td bgcolor="b8cce4"&gt;&lt;b&gt;Beitostølen&lt;/b&gt;&lt;/td&gt;
          &lt;td&gt;120&lt;/td&gt;
          &lt;td&gt;30&lt;/td&gt;
          &lt;td&gt;40&lt;/td&gt;
          &lt;td&gt;100&lt;/td&gt;
          &lt;td&gt;75&lt;/td&gt;
          &lt;td&gt;$&lt;/td&gt;
        &lt;/tr&gt;
  
  &lt;!--here I want it to ask for date using &lt;input type="date" name="example"&gt;
   Example: from &lt;input type="date" name="from"&gt; to &lt;input type="date" name="to"&gt;
   then calculate price for the amount of days that becomes, lets say each day is 1000.
   this is to be calculated together with what is selected in table--&gt;
  
        &lt;script type="text/javascript"&gt;
          (function() {
            var tds = document.querySelectorAll('tr td:not(:last-child)');
            for (var td in tds) {
              tds[td].addEventListener('click', function(evt) {
                evt.target.classList.toggle('selected');
                var total = 0;
                var parentTr = evt.target.parentNode;
                var selected = parentTr.querySelectorAll('.selected');
                for (var k in selected) {
                  if (selected[k].innerText) {
                    total += parseInt(selected[k].innerText);
                  }
                }
                parentTr.querySelector('td:last-child').innerText = total;
              });
            }
          })();
          &lt;!-- The script currently works with this setup, but I want to change it, I want it to be a two dimentional array setup. I mean, so it prints the current table with pre-printed info in the script  --&gt;
        &lt;/script&gt;
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>If anything is unclear, feel free to ask, and Ill try to explain as good as possible</p>
  
  <p>JSFIDDLE: <a href="https://jsfiddle.net/zfcknc5m/1/" rel="nofollow">https://jsfiddle.net/zfcknc5m/1/</a></p>