From 4f467fa2b2b6051725691ec1da6109edf458eb13 Mon Sep 17 00:00:00 2001 From: lolabird Date: Wed, 27 Dec 2023 02:25:18 -0700 Subject: [PATCH] Change classes and class handling for clear all and clear error buttons --- index.html | 4 ++-- script.js | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index fe8d50b..ad94e22 100644 --- a/index.html +++ b/index.html @@ -11,8 +11,8 @@
0
- - + + diff --git a/script.js b/script.js index 498c343..716cc96 100644 --- a/script.js +++ b/script.js @@ -12,9 +12,9 @@ function displayToScreen() { let calc = new Calculator; screen.textContent = calc.calculate(screen.textContent); - } else if (this.className == "clear") { + } else if (this.classList.contains("all")) { screen.textContent = "0"; - } else if (this.className == "back") { + } else if (this.classList.contains("error")) { screen.textContent = screen.textContent.trimEnd() screen.textContent = screen.textContent.slice(0, -1); @@ -26,7 +26,6 @@ function displayToScreen() { let screenContent = screen.textContent; // Add some logic for handling negatives with - - // 0 on a trailing decimal point // Add key support for (let i = 0; i < screenContent.length; i++ ) { @@ -86,7 +85,6 @@ function divideDecimals(a, b) { const divisor = Math.pow(10, maxDec); return(a * divisor) / (b * divisor); - }