Skip to content

Commit cb9f1ea

Browse files
authored
Merge branch 'master' into local-storage
2 parents ce382d5 + ee297e4 commit cb9f1ea

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ function convertToPercentage(button) {
9797
}
9898
}
9999

100-
clearHistoryBtn.addEventListener("click", () => {
101-
historyElement.innerHTML = "";
102-
});
100+
103101

104102
function deteLastEntry(button) {
105103
if (button === "DE") {
@@ -232,7 +230,7 @@ function userClicksOnEqualButton(button) {
232230
} else {
233231
let result = eval(replacedArray.join(""));
234232
const history = getHistoryFromLocalStorage()
235-
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.
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
236234
replacedArray.splice(replacedArray.length, 0, "=", result);
237235
displayResult(replacedArray, result);
238236
screen.innerText = !Number.isFinite(result)

0 commit comments

Comments
 (0)