diff --git a/2620.counter.js b/2620.counter.js new file mode 100644 index 0000000..08a8815 --- /dev/null +++ b/2620.counter.js @@ -0,0 +1,21 @@ +/** + * URL of this problem + * https://leetcode.com/problems/counter/ + */ + +/** + * @param {number} n + * @return {Function} counter + */ +var createCounter = function (n) { + return function () { + return n++; + }; +}; + +/** + * const counter = createCounter(10) + * counter() // 10 + * counter() // 11 + * counter() // 12 + */