Skip to content

Commit e072e77

Browse files
committed
feat(JS) add conditional statement to control how many li element there are
1 parent c4272b5 commit e072e77

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,24 @@ function userClicksOnEqualButton(button) {
218218
// divideByZero(screen, result);
219219
data = [];
220220
data.push(result);
221-
historyEntries.forEach(entry => {
221+
historyEntries.forEach((entry, index) => {
222222
console.log(entry);
223223
history.push(entry);
224+
if(history.length > 3) {
225+
history.pop()
226+
}
224227
console.log(history);
225-
historyElement.innerHTML += `<li>${entry.join(" ")}</li>`
228+
historyElement.innerHTML += `<li> ${entry.join(" ")}</li>`
229+
if(historyElement.childElementCount > 10) {
230+
console.log("hi")
231+
historyElement.firstElementChild.remove()
232+
233+
}
234+
226235
});
236+
237+
238+
227239

228240
}
229241
} catch (e) {

0 commit comments

Comments
 (0)