×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Text
Posted by: Brad Rice
Added: Sep 8, 2017 12:12 PM
Views: 8
Tags: javascript
Functional javascript increment function
  1. var increment = () => {
  2.   var counter = 0;
  3.   var incrementCount = () => {
  4.     counter = counter + 1;
  5.     return counter;
  6.   }
  7.   return incrementCount;
  8. }
  9.  
  10. counter = increment();
  11.  
  12. // call this like this counter() -> the first time will return 1 and then increment every time after