Skip to content

Commit 572da3d

Browse files
committed
improve readability by creating ZERO & ZERO_DOT constant
1 parent 423aee0 commit 572da3d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const btns = document.querySelectorAll("[data-value]");
22
let screen = document.querySelector("[data-screen]");
33
const operators = document.querySelectorAll("[data-operator]");
44
const operatorRegex = /[\/*\-+]/;
5+
const ZERO = 0;
6+
const ZERO_DOT = '0.';
57

68
let data = [];
79

@@ -139,7 +141,7 @@ function insertClosingParenthesis(button) {
139141
}
140142

141143
function handlingZeroFollowedByAdecimal(button) {
142-
if (Number(button) === 0 && screen.innerText.startsWith("0.")) {
144+
if (Number(button) === ZERO && screen.innerText.startsWith(ZERO_DOT)) {
143145
screen.innerText += button;
144146
}
145147
}

0 commit comments

Comments
 (0)