diff --git a/problems/counter.js b/problems/counter.js new file mode 100644 index 0000000..008c337 --- /dev/null +++ b/problems/counter.js @@ -0,0 +1,16 @@ +/** + * @param {number} n + * @return {Function} counter + */ +var createCounter = function(n) { + return function() { + return n++; + }; +}; + +/** + * const counter = createCounter(10) + * counter() // 10 + * counter() // 11 + * counter() // 12 + */