File tree Expand file tree Collapse file tree 1 file changed +21
-15
lines changed
Expand file tree Collapse file tree 1 file changed +21
-15
lines changed Original file line number Diff line number Diff line change @@ -218,21 +218,11 @@ function userClicksOnEqualButton(button) {
218218 // divideByZero(screen, result);
219219 data = [ ] ;
220220 data . push ( result ) ;
221- historyEntries . forEach ( ( entry , index ) => {
222- console . log ( entry ) ;
223- history . push ( entry ) ;
224- if ( history . length > 3 ) {
225- history . pop ( )
226- }
227- console . log ( history ) ;
228- historyElement . innerHTML += `<li> ${ entry . join ( " " ) } </li>`
229- if ( historyElement . childElementCount > 10 ) {
230- console . log ( "hi" )
231- historyElement . firstElementChild . remove ( )
232-
233- }
234-
235- } ) ;
221+
222+ createHistoryList ( historyEntries , historyElement , history )
223+
224+
225+
236226
237227
238228
@@ -271,4 +261,20 @@ function displayResult(array, outcome) {
271261 array = [ ] ;
272262 array . push ( outcome ) ;
273263}
264+
265+
266+ function createHistoryList ( array , element , history ) {
267+ array . forEach ( ( entry , index ) => {
268+
269+ history . push ( entry ) ;
270+
271+ element . innerHTML += `<li> ${ entry . join ( " " ) } </li>`
272+ if ( element . childElementCount > 10 ) {
273+ console . log ( "hi" )
274+ element . firstElementChild . remove ( )
275+ }
276+ } ) ;
277+ }
278+
279+
274280// functions creations ends
You can’t perform that action at this time.
0 commit comments