From dae22fdf4e1554bb4f0de7d90f2f9e734a3b985e Mon Sep 17 00:00:00 2001 From: Yuya Minamide Date: Fri, 2 Jun 2023 21:52:59 -0700 Subject: [PATCH] solved 2620. Counter --- 2620.counter.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 2620.counter.js 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 + */