Skip to content

Commit 9722fc1

Browse files
committed
feat(JS): replace if and else if statement in if statement with condition /[\/*\-+]/.test(buttonValue) by a ternary operator
1 parent ed6145f commit 9722fc1

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ btns.forEach((btn) => {
6060
if (data.slice(-1)[0] === ".") {
6161
data.pop();
6262
}
63-
if (buttonValue === "*") {
64-
buttonValue = "x";
65-
} else if (buttonValue === "/") {
66-
buttonValue = "÷";
67-
}
63+
buttonValue === "*" ? buttonValue = "X" : buttonValue === "/" ? buttonValue = "÷" : buttonValue;
64+
6865
data.push(buttonValue);
6966
screen.innerText = data.join("");
7067
}

0 commit comments

Comments
 (0)