Skip to content

Commit cb943a7

Browse files
author
Tom Tarpey
committed
done the closure stretch counter factory
1 parent 183af1c commit cb943a7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

assignments/closure.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ console.log(newCounter()); // 2
4141
// ==== Challenge 3: Create a counter function with an object that can increment and decrement ====
4242
const counterFactory = () => {
4343
// Return an object that has two methods called `increment` and `decrement`.
44+
let count = 0;
4445
// `increment` should increment a counter variable in closure scope and return it.
46+
const increment = function() {count++; return count};
4547
// `decrement` should decrement the counter variable and return it.
46-
};
48+
const decrement = function() {count; return count};
49+
};

0 commit comments

Comments
 (0)