Untitled
num = 5; let counter = (function test(num) { return function(x=1) { for (let i = 0; i < x; i++) { ++num } return num; } })(num); console.log(counter()); console.log(counter(2)); console.log(counter(3));
num = 5; let counter = (function test(num) { return function(x=1) { for (let i = 0; i < x; i++) { ++num } return num; } })(num); console.log(counter()); console.log(counter(2)); console.log(counter(3));