Skip to content

Commit

Permalink
add delete key
Browse files Browse the repository at this point in the history
  • Loading branch information
dwnorm2 committed Jan 26, 2024
1 parent 19814b1 commit c08eb56
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class Calculator {
clear() {
this.current = "";
}

delete() {
this.current = this.current.toString().split("").slice(0, -1).join("");
}
}

let calc = new Calculator();
Expand Down Expand Up @@ -177,6 +181,11 @@ document.addEventListener("keydown", function (event) {
showCurrentNum();
display.textContent = "0";
break;

case "Backspace":
calc.delete();
showCurrentNum();
break;
}
});

Expand Down

0 comments on commit c08eb56

Please sign in to comment.