From 5b4ab061e180c99c35e28f0b9e6ac87957368b70 Mon Sep 17 00:00:00 2001 From: Shahriar Shatil <52494840+ShatilKhan@users.noreply.github.com> Date: Tue, 6 Feb 2024 20:29:43 +0600 Subject: [PATCH] Time: 46 ms (84.42%) | Memory: 48.6 MB (22.43%) - LeetSync --- 2732-counter/counter.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 2732-counter/counter.js diff --git a/2732-counter/counter.js b/2732-counter/counter.js new file mode 100644 index 0000000..d2e5364 --- /dev/null +++ b/2732-counter/counter.js @@ -0,0 +1,17 @@ +/** + * @param {number} n + * @return {Function} counter + */ +function createCounter(start) { + let count = start; + return function(){ + return count++; + } +} + +/** + * const counter = createCounter(10) + * counter() // 10 + * counter() // 11 + * counter() // 12 + */ \ No newline at end of file