HomeTracks
Explorer···
THEEBUG
Completed0/11
Score0
JSlesson6.js×
THEEBUGlesson6.js
1
function makeCounter() {
2
let count = 0;
3
return function () {
4
count ______ 1;
5
return count;
6
};
7
}
8
 
9
const counter = makeCounter();
10
console.log(counter()); // 1
11
console.log(counter()); // 2
$[system] Theebug ready. Happy coding!
Code BlocksDrag blocks into the drop zones above
4 blocks available
+=
=
==
*=
Game Panel
0:000 pts
Level 6 of 11Closures
0/1 slots correct
Objective
Complete the closure so each call to counter() increases and returns the running count
Expected Output
1
2
Debug says:
This inner function needs to REMEMBER and increase count every time it's called — that's a closure! Which operator adds 1 and saves the new value back into count?
Debug the Worm