I have made a function that should build the number for me, which was working and for some reason has stopped.
function buildNumber(num){
console.log(num);
if (calcState === true && currentNumber.toString().length < 9){
if(currentNumber === 0){
if (num === "."){
currentNumber = Number(`${currentNumber}${num}`);
console.log(currentNumber);
checkDecimal = true;
updateDisplay();
} else if (num >=0 && num <= 9) {
currentNumber = num;
console.log(currentNumber);
updateDisplay();
}
} else {
if (num === "."){
currentNumber = Number(`${currentNumber}${num}`);
checkDecimal = true;
console.log(currentNumber);
updateDisplay();
} else if (num >=0 && num <= 9) {
currentNumber = Number(`${currentNumber}${num}`);
console.log(currentNumber);
updateDisplay();
}
}
}
}
The event listener is triggered like so:
pointBtn.addEventListener("click", function(){
console.log("Decimal pressed")
if (checkDecimal === false){
buildNumber(".");
}
});
I'm just at a loss as to why it isn't triggering, the console.log just inside buildNumber() shows that the value is there when I click the button, it just doesn't do what I originally had it doing. Is there something glaringly obvious that I've missed?