Clousure solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\nLook like can be solved by JavaScript closure.\n\n# Approach\n Describe your approach
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nLook like can be solved by JavaScript closure.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\nUse JavaScript closure store a variable num, then inside the return function plus and assign the variable, and return it.\n\n# Complexity\n- Time complexity: O(1)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nfunction createCounter(n: number): () => number {\n    let num = n - 1;\n    return function() {\n        return num += 1\n    }\n}\n\n\n/** \n * const counter = createCounter(10)\n * counter() // 10\n * counter() // 11\n * counter() // 12\n */\n```
['TypeScript', 'JavaScript']