12 lines
256 B
JavaScript
12 lines
256 B
JavaScript
function setupCounter(val) {
|
|
return function counter() {
|
|
return val++;
|
|
}
|
|
}
|
|
|
|
let counter1 = setupCounter(0);
|
|
console.log(counter1());
|
|
console.log(counter1());
|
|
let counter2 = setupCounter(10);
|
|
console.log(counter2());
|
|
console.log(counter2()); |