I am trying to learn callbacks in JS, and I do not understand why the following code will not work:
function timer(){
let count = 0;
return function (){
function inc(){
count++;
}
function getCount(){
return count;
}
}
}
let t = timer();
t.inc();
t.inc();
t.inc();
console.log(t.getCount());
incandgetCountare not members of the function returned bytimer- they are "private" functions within the function returned bytimer