Question PRG-JS-0047
MediumWhat is the output of this program?
const counter = (() => { let c = 0; return () => ++c; })();
counter(); counter();
console.log(counter());
- A.
3
- B.
1
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
JavaScript question
What is the output of this program?
const counter = (() => { let c = 0; return () => ++c; })();
counter(); counter();
console.log(counter());
3
1
Sign up free to see the answer and a step-by-step explanation.
2
undefined