'How to stop inputA from changing?

so how can i make inputA and inputB have different numbers? right now inputA is the same as inputB ‎‎‎‎‎‎‎‎‎‎‎

const numbers = document.querySelectorAll(".numbers");
numbers.forEach((number) => {
  number.addEventListener("click", () => {
    display.textContent += number.innerHTML;
    inputA = display.textContent;
    console.log(inputA + "a")
  });
});

const functions = document.querySelectorAll(".func");
functions.forEach((fnction) => {
  fnction.addEventListener("click", () => {
    display.textContent = "";
    operatorInput = fnction.innerHTML;
    console.log(operatorInput)

    
      numbers.forEach((number) => {
      number.addEventListener("click", () => {
        
        inputB = display.textContent;
        console.log(inputB + "b");
      });
    });

  })
})


Solution 1:[1]

First of all document.querySelectorAll doesnt return array. The proper usage is:

Array.from(document.querySelectorAll(selector)).forEach... 

Please check the reference https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll

You dont declare variables inputA and inputA (let inputA, let inputB). What's more, display.textContent in case B is equal to the display.textcontent from the case A. Because it's the same element. Despite you attempt to clear textContent in the upperscope (case B) it has no effect.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rodion