From 84885aa0c99bdd8b18f8f8a2b54ec1e851950013 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Fri, 12 May 2023 17:30:08 +0200 Subject: [PATCH] =?UTF-8?q?problems(js):=20add=20=E2=80=9C2620.=20Counter?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matej Focko --- problems/counter.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 problems/counter.js 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 + */