From 108362dd23281246cc137a47303698cac01d76c9 Mon Sep 17 00:00:00 2001 From: Deven <63876261+devenperez@users.noreply.github.com> Date: Thu, 21 Nov 2024 19:33:43 -0500 Subject: [PATCH] Time: 49 ms (67.57%), Space: 48.8 MB (54.6%) - 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..c03f502 --- /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