File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 88
99 // Return a function that when invoked increments and returns a counter variable.
1010
11- const counter = ( count ) => {
11+ const counter = ( ) => {
12+
13+ let count = 0 ;
1214 function counterIncrement ( ) {
13- return count ++ ;
15+ return ++ count ;
1416 }
1517 return counterIncrement ;
1618 } ;
17- const newCounter = counter ( 1 ) ;
19+ const newCounter = counter ( ) ;
1820console . log ( newCounter ( ) ) ;
1921console . log ( newCounter ( ) ) ;
2022console . log ( newCounter ( ) ) ;
@@ -46,7 +48,7 @@ const counterFactory = () => {
4648 return ++ param ;
4749 } ,
4850 decrement : function decrement ( ) {
49- return param -- ;
51+ return -- param ;
5052 }
5153 }
5254} ;
@@ -56,7 +58,7 @@ const test = counterFactory();
5658 console . log ( test . increment ( ) ) ;
5759 console . log ( test . increment ( ) ) ;
5860 console . log ( test . increment ( ) ) ;
59- console . log ( `--------Decrement starts here---------------------------` ) ;
61+ console . log ( `-------- Decrement starts here ---------------------------` ) ;
6062 console . log ( test . decrement ( ) ) ;
6163 console . log ( test . decrement ( ) ) ;
6264 console . log ( test . decrement ( ) ) ;
You can’t perform that action at this time.
0 commit comments