Simple JavaScript Counter with Closure
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n- The time complexity of both the createCounter function and the returned function is constant, since there are no loops or recursive calls involved. Each call to the returned function simply increments a variable and returns its previous value.\n\nTime complexity: \uD835\uDC42(1)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n- The space complexity is determined by the storage of the variable n within the closure. Regardless of the initial value of n, only one integer is stored and manipulated.\n\nSpace complexity: \uD835\uDC42(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nvar createCounter = function(n) {\n    \n    return function() {\n        return n++;        \n    };\n};\n```
['JavaScript']