Quiz · Closures and this · lesson 3 of 11
Quiz — two counters
What does the program print?
function makeCounter() {
let count = 0;
return () => {
count += 1;
return count;
};
}
const a = makeCounter();
const b = makeCounter();
console.log(a(), a(), b());Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.