You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
button.click();// Trigger the click event for the corresponding button
35
-
}
27
+
}
36
28
37
29
if(event.code==="Backspace"){
38
30
letnewArray=data.slice(ZERO,-1);
@@ -43,13 +35,11 @@ function handleKeyPress(event) {
43
35
}
44
36
}
45
37
46
-
if(event.code==="Enter"){
38
+
if(event.code==="Enter"){
47
39
userClicksOnEqualButton("=");
48
40
}
49
-
50
41
}
51
42
52
-
53
43
constoperatorRegex=/[\/*\-+]/;
54
44
constZERO=0;
55
45
constZERO_DOT="0.";
@@ -97,8 +87,6 @@ function convertToPercentage(button) {
97
87
}
98
88
}
99
89
100
-
101
-
102
90
functiondeteLastEntry(button){
103
91
if(button==="DE"){
104
92
letnewArray=data.slice(ZERO,-1);
@@ -229,21 +217,21 @@ function userClicksOnEqualButton(button) {
229
217
screen.innerText="0÷0 is an invalid format. Press AC";
230
218
}else{
231
219
letresult=eval(replacedArray.join(""));
232
-
consthistory=getHistoryFromLocalStorage()
233
-
history.push([...replacedArray,"=",result].join('').split(','));// Used slice() at first. But slice() is not sufficient because it only creates a shallow copy of the array, and modifications to the new array will still affect the original array. The spread syntax ([...replacedArray]), which creates a shallow copy as well, is a concise way to create a new array with the same elements as the existing array. While ensuring that modifications to historyEntries do not affect replacedArray, and vice versa
220
+
consthistory=getHistoryFromLocalStorage();
221
+
history.push([...replacedArray,"=",result].join("").split(","));// Used slice() at first. But slice() is not sufficient because it only creates a shallow copy of the array, and modifications to the new array will still affect the original array. The spread syntax ([...replacedArray]), which creates a shallow copy as well, is a concise way to create a new array with the same elements as the existing array. While ensuring that modifications to historyEntries do not affect replacedArray, and vice versa
0 commit comments