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
@@ -232,18 +231,21 @@ function userClicksOnEqualButton(button) {
232
231
screen.innerText="0÷0 is an invalid format. Press AC";
233
232
}else{
234
233
letresult=eval(replacedArray.join(""));
235
-
lethistoryEntries=[[...replacedArray,"=",result]];// 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.
234
+
consthistory=getHistoryFromLocalStorage()
235
+
history.push([...replacedArray,"=",result]);// 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