Easy iterative example for beginners 🧨. Please Up vote  🫰🏻
Approach\nThinking in multiple ways and knowing the fundamentals is Great\n\n# Complexity\n- Time complexity:\no(1)\n\n- Space complexity:\no(1)\n\n# Code\n\n//
# Approach\nThinking in multiple ways and knowing the fundamentals is Great\n\n# Complexity\n- Time complexity:\no(1)\n\n- Space complexity:\no(1)\n\n# Code\n```\n// Expanded version and simple\nvar createCounter = function (n) {\n    var count=0;\n    var temp=0;\n    return function () {\n        if(count===0){\n            count+=1\n            temp=n\n            return n\n        }\n        else{\n            temp+=1\n            return temp\n        }\n    }\n};\n\n// For one-liners and functional programmers\n// let createCounter = (n) => () => n++\n\n```
['JavaScript']