JS Easy solution :- Closure
Approach\nA closure has been utilized in our code. This enables the retention of variable values and function declarations even after the function has finished 
# Approach\nA closure has been utilized in our code. This enables the retention of variable values and function declarations even after the function has finished executing.\n\n\n\n\n\n\n# Code\n```\n/**\n * @param {number} n\n * @return {Function} counter\n */\nvar createCounter = function(n) {\n    let counter = n;  //created a counter variable to remember the value\n    return function( ) {\n        return counter++;\n    };\n};\n\n/** \n * const counter = createCounter(10)\n * counter() // 10\n * counter() // 11\n * counter() // 12\n */\n```
['JavaScript']