✅✅ JavaScript || TypeScript Solution || Begineer Friendly ✅✅
\n\n# Approach\n Describe your approach to solving the problem. \nWe are getting n in the parent function as an argument. We have to return n and increase it by
\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe are getting `n` in the parent function as an argument. We have to return n and increase it by one `n++`.\n\n# Code\n```TypeScript []\nfunction createCounter(n: number): () => number {\n    return function() {\n        return n++;\n    }\n}\n\n\n/** \n * const counter = createCounter(10)\n * counter() // 10\n * counter() // 11\n * counter() // 12\n */\n```\n\n```JavaScript []\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n    return function() {\n        return n++;\n    };\n};\n\n/** \n * const counter = createCounter(10)\n * counter() // 10\n * counter() // 11\n * counter() // 12\n */\n```
['TypeScript', 'JavaScript']