How can I declare a variable inside a JavaScript function, so the following behavior happens?
The initialization should happen once.
function count() {
let_special count = 0;
count++;
if (count == 3) {
count = 5;
}
return count;
}
let a = count(); // a = 1
let b = count(); // a = 2
let c = count(); // a = 5
let d = count(); // a = 6
let e = count(); // a = 7
If I remember correctly, there was a way to do that but right now I can't find it on Google.
Thanks!