title: can't figure out the logic to make the values add up
body: <p>I'm making a calculator project but as for now, my calculator can only perform the action of summing two numbers instead of adding up all the numbers that we add up later. I can't figure out the logic to make this work for it to calculate the numbers in a sequencial manner. Can anyone help me with this?</p>
  <p>For example, now when you press 2 + 2 it returns 4, but when you press 2 + 2 + 4 it returns 6 and it should behave like a normal calculator, returning 8</p>
  <p>I would relaly appreciate it thank you! Here is the script for my program:</p>
  <pre><code>var select = document.querySelector('#buttons')
  var operating = document.querySelector('#operators')
  let buttonequals = document.getElementById('button-equals')
  
  select.addEventListener('click', selector)
  operating.addEventListener('click', operatorSign)
  
  
  let value;
  let target;
  let firstResult = 0;
  let secondResult = 0;
  let finalResult = 0;
  let operand = &quot;&quot;;
  
  
  function selector(event) {
    target = event.target;
    if (target.matches('button')) {
      value = target.innerHTML
      value = Number(value);
  
      result = document.querySelector('#output').value += value
      result = Number(result)
  
  
      if (operand === &quot;&quot;) {
        firstResult = Number(result)
        console.log(firstResult)
      } else {
        secondResult = Number(result)
        console.log(secondResult)
      }
  
  
    }}
  
  
  function operatorSign(e) {
      let operator = e.target;
      if (operator.matches('button')) {
        operand = operator.innerHTML
  
        if (operand !== &quot;=&quot;) {
            document.querySelector('#output').value = &quot;&quot;
  
        }
  
      }
  }
  
  
  function calculate() {
  
  
    if (operand === &quot;+&quot;) {
      finalResult = firstResult + secondResult
      document.querySelector('#output').value = finalResult
      console.log(finalResult)
    } else if (operand === &quot;-&quot;) {
      finalResult = firstResult - secondResult
      document.querySelector('#output').value = finalResult
    } else if (operand === &quot;*&quot;) {
      finalResult = firstResult * secondResult
      document.querySelector('#output').value = finalResult
    } else if (operand === &quot;/&quot;) {
      finalResult = firstResult / secondResult
      document.querySelector('#output').value = finalResult
    }
  
  }
  </code></pre>