title: "Uncaught TypeError: Cannot read properties of undefined (reading 'toString') when clicking number button
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class Calculator {
    constructor(previousOperandTextElement, currentOperandTextElement) {
      this.previousOperandTextElement = previousOperandTextElement
      this.currentOperandTextElement = currentOperandTextElement
      this.clear()
    }
  
    clear() {
      this.previousOperandTextElement = ''
      this.currentOperandTextElement = ''
      this.operation = undefined
    }
  
    delete() {
  
    }
  
    appendNumber(number) {
      this.currentOperand = this.currentOperand.toString() + number.toString()
    }
  
    chooseOperator(operation) {
  
    }
  
    compute() {
  
    }
  
    updateDisplay() {
      this.currentOperandTextElement.innerHTML = this.currentOperand
    }
  
  
  }
  
  const numberButtons = document.querySelectorAll('[data-number]')
  const operationButtons = document.querySelectorAll('[data-operation]')
  const equalsButton = document.querySelector('[data-equals]')
  const deleteButton = document.querySelector('[data-delete]')
  const allClearButton = document.querySelector('[data-all-clear]')
  const previousOperandTextElement = document.querySelector('[data-previous-operand]')
  const currentOperandTextElement = document.querySelector('[data-current-operand]')
  
  const calculator = new Calculator(previousOperandTextElement, currentOperandTextElement)
  
  numberButtons.forEach(button =&gt; {
    button.addEventListener('click', () =&gt; {
      calculator.appendNumber(button.innerHTML)
      calculator.updateDisplay()
    })
  })</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>*,
  *::before,
  *::after {
    box-sizing: border-box;
    font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
    font-weight: normal;
  }
  
  body {
    padding: 0;
    margin: 0;
    background: linear-gradient(to right, #00AAFF, #00FF6C);
  }
  
  .calculator-grid {
    display: grid;
    justify-content: center;
    align-content: center;
    min-height: 100vh;
    grid-template-columns: repeat(4, 100px);
    grid-template-rows: minmax(120px, auto) repeat(5, 100px);
  }
  
  .calculator-grid button {
    cursor: pointer;
    font-size: 2rem;
    border: 1px solid white;
    outline: none;
    background-color: rgba(255, 255, 255, .75);
  }
  
  .calculator-grid button:hover {
    background-color: rgba(255, 255, 255, .9);
  }
  
  .span-two {
    grid-column: span 2;
  }
  
  .output {
    grid-column: 1 / -1;
    background-color: rgba(0, 0, 0, 0.75);
    border: solid 5px green;
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
  }
  
  .output .previous-operand {
    color: rgba(255, 255, 255, .75);
    font-size: 1.5rem;
  }
  
  .output .current-operand {
    color: rgba(255, 255, 255, .75);
    font-size: 2.5rem;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
    &lt;title&gt;Calculator&lt;/title&gt;
    &lt;link rel="stylesheet" href="calculator.css"&gt;
    &lt;script src="calculator.js" defer&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;div class="calculator-grid"&gt;
      &lt;div class="output"&gt;
        &lt;div data-previous-operand class="previous-operand"&gt;&lt;/div&gt;
        &lt;div data-current-operand class="current-operand"&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;button data-all-clear class="span-two"&gt;AC&lt;/button&gt;
      &lt;button data-delete&gt;DEL&lt;/button&gt;
      &lt;button data-operation&gt;÷&lt;/button&gt;
      &lt;button data-number&gt;1&lt;/button&gt;
      &lt;button data-number&gt;2&lt;/button&gt;
      &lt;button data-number&gt;3&lt;/button&gt;
      &lt;button data-operation&gt;*&lt;/button&gt;
      &lt;button data-number&gt;4&lt;/button&gt;
      &lt;button data-number&gt;5&lt;/button&gt;
      &lt;button data-number&gt;6&lt;/button&gt;
      &lt;button data-operation&gt;+&lt;/button&gt;
      &lt;button data-number&gt;7&lt;/button&gt;
      &lt;button data-number&gt;8&lt;/button&gt;
      &lt;button data-number&gt;9&lt;/button&gt;
      &lt;button data-operation&gt;-&lt;/button&gt;
      &lt;button data-number&gt;.&lt;/button&gt;
      &lt;button data-number&gt;0&lt;/button&gt;
      &lt;button data-equals class="span-two"&gt;=&lt;/button&gt;
    &lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>