From 61d62def61005c804c138d71da16c159825b0140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Chac=C3=B3n=20Guti=C3=A9rrez?= <138903866+joseantoniochacon@users.noreply.github.com> Date: Thu, 13 Jun 2024 20:16:26 -0600 Subject: [PATCH] Time: 54 ms (36.24%), Space: 48.9 MB (40.16%) - LeetHub --- 2620-counter/2620-counter.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 2620-counter/2620-counter.js diff --git a/2620-counter/2620-counter.js b/2620-counter/2620-counter.js new file mode 100644 index 0000000..ef80f10 --- /dev/null +++ b/2620-counter/2620-counter.js @@ -0,0 +1,17 @@ +/** + * @param {number} n + * @return {Function} counter + */ +var createCounter = function(n) { + + return function() { + return n++; + }; +}; + +/** + * const counter = createCounter(10) + * counter() // 10 + * counter() // 11 + * counter() // 12 + */ \ No newline at end of file