mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 03:27:07 +00:00
Time: 49 ms (67.57%), Space: 48.8 MB (54.6%) - LeetHub
This commit is contained in:
@@ -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
|
||||||
|
*/
|
||||||
Reference in New Issue
Block a user