Skip to content

Commit 2e1154e

Browse files
author
Paul Fang
committed
closure.js edits
1 parent 0c1b2eb commit 2e1154e

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/closure.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ const counterFactory = () => {
3131
const limitFunctionCallCount = (cb, n) => {
3232
// Should return a function that invokes `cb`.
3333
// The returned function should only allow `cb` to be invoked `n` times.
34+
let count = 0;
35+
36+
if (count < n) {
37+
cb();
38+
count++;
39+
}
3440
};
3541

3642
/* STRETCH PROBLEM */
@@ -52,3 +58,4 @@ module.exports = {
5258
cacheFunction,
5359
limitFunctionCallCount,
5460
};
61+

0 commit comments

Comments
 (0)