Easy and Straightforward Javascript Solution in O(1) Time And Space Complexity ✔✔.
Intuition \n Describe your first thoughts on how to solve this problem. \n - n is local to createCounter function.\n - n is global to counter function.\n Since 
# Intuition \n<!-- Describe your first thoughts on how to solve this problem. -->\n - n is local to createCounter function.\n - n is global to counter function.\n Since in every call we have to return n and in next call we have to\n return n+1 so what we do is we will first store value of n in temp   variable and then we increase value of n by 1 and return temporary value and since n is global to counter so change in value of n will be reflect in next call (In the next call value of n will be curr value+1 and that will be our ans). \n# Approach\n<!-- Describe your approach to solving the problem. -->\n  - let temp=n\n  - n+=1\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```\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function counter(n) {\n    return function() {\n           let curr=n;\n           n+=1;\n           return curr;\n    };\n};\n\n/** \n * const counter = createCounter(10)\n * counter() // 10\n * counter() // 11\n * counter() // 12\n */\n```
['JavaScript']