JavaScript
32.1K subscribers
1.06K photos
10 videos
33 files
737 links
A resourceful newsletter featuring the latest and most important news, articles, books and updates in the world of #javascript 🚀 Don't miss our Quizzes!

Let's chat: @nairihar
Download Telegram
CHALLENGE

function createCounter() {
let count = 0;
return {
increment: () => ++count,
decrement: () => --count,
getValue: () => count
};
}

const counter1 = createCounter();
const counter2 = createCounter();
counter1.increment();
counter1.increment();
counter2.increment();
console.log(counter1.getValue(), counter2.getValue());
counter1.decrement();
console.log(counter1.getValue(), counter2.getValue());
3🤩1
What is the output?
Anonymous Quiz
21%
1 1 0 0
34%
2 1 1 0
36%
2 1 1 1
9%
3 2 2 1
6