File tree 2 files changed +17
-3
lines changed
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ const backBtn = document.querySelector(".backsp-btn");
3
3
const equalToBtn = document . querySelector ( ".equal-to" ) ;
4
4
const btnClick = document . querySelectorAll ( ".btn" ) ;
5
5
const inputbtnValue = document . querySelector ( ".number-box" ) ;
6
+ const operationBtn = document . querySelectorAll ( ".btn .operation-btn" ) ;
6
7
7
8
btnClick . forEach ( myFunction ) ;
8
9
@@ -23,6 +24,9 @@ function evaluateFunction() {
23
24
const equalTo = eval ( inputbtnValue . value ) ;
24
25
inputbtnValue . value = equalTo ;
25
26
buttonFunctionDisable ( false ) ;
27
+ if ( inputbtnValue . value . length === inputbtnValue . maxLength ) {
28
+ buttonFunctionDisable ( true ) ;
29
+ }
26
30
}
27
31
}
28
32
@@ -42,7 +46,17 @@ function myFunction(button) {
42
46
inputbtnValue . value += btnClick ;
43
47
}
44
48
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
+ }
46
60
}
47
61
} ) ;
48
- }
62
+ }
Original file line number Diff line number Diff line change 13
13
< input type ="text " id ="number-box " class ="number-box " minlength ="1 " maxlength ="10 ">
14
14
< div class ="calculator-container ">
15
15
< button class ="clear-btn "> AC</ button >
16
- < button class ="btn " data-set ="% "> %</ button >
17
16
< button class ="backsp-btn "> < i class ="fa-solid fa-delete-left "> </ i > </ button >
17
+ < button class ="btn operation-btn " data-set ="% "> %</ button >
18
18
< button class ="btn operation-btn " data-set ="/ "> ÷</ button >
19
19
</ div >
20
20
< div class ="calculator-container ">
You can’t perform that action at this time.
0 commit comments