Skip to content

Commit 1a562d3

Browse files
committed
(feat:JS): get rid of the comma using join() and split() so user can see them
1 parent e2cedab commit 1a562d3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ function userClicksOnEqualButton(button) {
232232
} else {
233233
let result = eval(replacedArray.join(""));
234234
const history = 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.
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.
236236
replacedArray.splice(replacedArray.length, 0, "=", result);
237237
displayResult(replacedArray, result);
238238
screen.innerText = !Number.isFinite(result)

0 commit comments

Comments
 (0)