Call calculator from dipslayToScreen

This commit is contained in:
lolabird 2023-12-26 21:25:33 -07:00
commit dce94d7165

View file

@ -9,7 +9,11 @@ buttons.forEach((button) => {
function displayToScreen() {
if (this.className == "equal") {
//equal
let calc = new Calculator;
console.log(screen.textContent)
screen.textContent = calc.calculate(screen.textContent) + " ";
console.log(typeof(screen.textContent))
} else if (this.className == "clear") {
//clear´
} else {
@ -24,14 +28,26 @@ function displayToScreen() {
}
}
}
if (screen.textContent === "0") {
screen.textContent = this.textContent + " ";
console.log("A button was pressed");
} else {
screen.textContent += this.textContent + " ";
console.log("A button was pressed");
}
screen.textContent += this.textContent;
console.log("A button was pressed")
}
}
function clear () {
}
function Calculator(str) {
console.log("Calculator has been called")
this.methods = {
"-": (a, b) => (a - b),