I am making a simple calculator with plain js, html and css. I am just starting but running into a little problem. I am trying to append numbers to the calculator so that it shows up on screen. I understand what to do but cant think of what i am missing. I am doing this at where if(secondValue !== '0') starts. The code down there only appends 2 numbers and then displays it on screen. For example "22". I am trying to get it so that a if a user clicks a number button on a calculator the screen will display something like "222222222" and so on. help?
const screenDisplay = document.querySelector('.screen_display');
const buttons = document.querySelectorAll('[id]')
let isBtnClicked =false;
let numberEntered = '';
let firstValue = "0";
//buttons do work
buttons.forEach(btn => {
btn.addEventListener('click', function() {
inputNumber(this.id)
});
});
function inputNumber(number) {
if (firstValue === "0") {
isBtnClicked = true;
screenDisplay.innerHTML = number;
}
let secondValue = ''
if (secondValue !== "0") {
secondValue = number;
screenDisplay.innerHTML = secondValue + number
}
}