title: How to add and subtract numbers in the DOM with Javascript?
body: <p>I am trying to figure out how to keep track of multiple Add and Remove counters with a Javascript Object and to update the DOM with the data in the object.</p>
  
  <p>My HTML:</p>
  
  <pre><code>&lt;div id="first-counter-box"&gt;
      &lt;div id="first-number"&gt;0&lt;/div&gt;
      &lt;div id="first-add" onclick="add(first)"&gt;&lt;/div&gt;
      &lt;div id="first-minus" onclick="minus(first)"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div id="second-counter-box"&gt;
      &lt;div id="second-number"&gt;0&lt;/div&gt;
      &lt;div id="second-add" onclick="add(second)"&gt;&lt;/div&gt;
      &lt;div id="second-minus" onclick="minus(second)"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My Javascript:</p>
  
  <pre><code>var dataObject = {
      firstCounter = 0;
      secondCounter = 0;
  }
  
  function add(counterId) {
      if (counterId==first) {
        dataObject.firstCounter++;
        var firstNumber = document.getElementbyID("first-number");
        firstNumber.innerHTML(dataObject.firstCounter);
      }
      else (counterId==second) {
          dataObject.secondCounter++;
          var secondNumber = document.getElementbyID("second-number");
          secondNumber.innerHTML(dataObject.secondCounter);
      }
  
  }
  
  function remove(counterId) {
      if (counterId==first) {
          dataObject.firstCounter--;
          var firstNumber = document.getElementbyID("first-number");
          firstNumber.innerHTML(dataObject.firstCounter);
      }
      else (counterId==second) {
          dataObject.secondCounter--;
          var secondNumber = document.getElementbyID("second-number");
          secondNumber.innerHTML(dataObject.secondCounter);
      }
  }
  </code></pre>
  
  <p>My aim is to update the data within the dataObject with the add() and remove() functions, and to update the DOM with updated information.</p>
  
  <p>I'm sure there is a better way to go about this than my gross javascript does it. Thank you!</p>