Do you know what will be the output of this code?
JavaScript
function make() {
let n = 0;
return () => ++n;
}
const a = make();
const b = make();
a();
a();
console.log(b());
Show answer and explanation
The answer is 1.
Every call to make() creates a new n. a and b close over different variables, so calling a twice doesn’t affect b.