Skip to content

Commit c4abb3c

Browse files
committed
Update v1.5
1 parent 5f9674d commit c4abb3c

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

app.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const backBtn = document.querySelector(".backsp-btn");
33
const equalToBtn = document.querySelector(".equal-to");
44
const btnClick = document.querySelectorAll(".btn");
55
const inputbtnValue = document.querySelector(".number-box");
6+
const operationBtn = document.querySelectorAll(".btn .operation-btn");
67

78
btnClick.forEach(myFunction);
89

@@ -23,6 +24,9 @@ function evaluateFunction() {
2324
const equalTo = eval(inputbtnValue.value);
2425
inputbtnValue.value = equalTo;
2526
buttonFunctionDisable(false);
27+
if (inputbtnValue.value.length === inputbtnValue.maxLength){
28+
buttonFunctionDisable(true);
29+
}
2630
}
2731
}
2832

@@ -42,7 +46,17 @@ function myFunction(button) {
4246
inputbtnValue.value += btnClick;
4347
}
4448
if (inputbtnValue.value.length === inputbtnValue.maxLength) {
45-
buttonFunctionDisable(true);
49+
if (
50+
btnClick === "+" ||
51+
btnClick === "-" ||
52+
btnClick === "*" ||
53+
btnClick === "/"
54+
) {
55+
buttonFunctionDisable(false);
56+
}
57+
else{
58+
buttonFunctionDisable(true);
59+
}
4660
}
4761
});
48-
}
62+
}

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<input type="text" id="number-box" class="number-box" minlength="1" maxlength="10">
1414
<div class="calculator-container">
1515
<button class="clear-btn">AC</button>
16-
<button class="btn" data-set="%">%</button>
1716
<button class="backsp-btn"><i class="fa-solid fa-delete-left"></i></button>
17+
<button class="btn operation-btn" data-set="%">%</button>
1818
<button class="btn operation-btn" data-set="/">÷</button>
1919
</div>
2020
<div class="calculator-container">

0 commit comments

Comments
 (0)