mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-10 00:09:06 +01:00
problems(js): add “2620. Counter”
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
19541ce1e7
commit
84885aa0c9
1 changed files with 16 additions and 0 deletions
16
problems/counter.js
Normal file
16
problems/counter.js
Normal file
|
@ -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
|
||||||
|
*/
|
Loading…
Reference in a new issue