Skip to content

Commit 89aa47b

Browse files
committed
feat(JS) create HISTORY_LIMIT const
1 parent 8ed8a18 commit 89aa47b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const operators = document.querySelectorAll("[data-operator]");
99
const operatorRegex = /[\/*\-+]/;
1010
const ZERO = 0;
1111
const ZERO_DOT = '0.';
12+
const HISTORY_LIMIT = 10;
1213
const history = [];
1314

1415
console.log(slidingPart)
@@ -265,13 +266,10 @@ function displayResult(array, outcome) {
265266

266267
function createHistoryList(array, element, history) {
267268
array.forEach((entry, index) => {
268-
269269
history.push(entry);
270-
271270
element.innerHTML += `<li> ${entry.join(" ")}</li>`
272-
if(element.childElementCount > 10) {
273-
console.log("hi")
274-
element.firstElementChild.remove()
271+
if(element.childElementCount > HISTORY_LIMIT) {
272+
element.firstElementChild.remove();
275273
}
276274
});
277275
}

0 commit comments

Comments
 (0)