encounter a problem, let go ("l") output "gol", go () ("l") output "gool", go () ("l") can output "goooool".
here is my solution
function go(r) {
let str = "go";
function a() {
str += "o";
}
function pro(m) {
if (m) {
console.log(str + "l");
} else {
a();
return pro;
}
}
if (!r) {
a();
return pro;
} else {
console.log(str + "l");
}
}
but I found that the last judgment did pro.
function go(r) {
let str = "go";
function a() {
str += "o";
}
function pro(m) {
if (m) {
console.log(str + "l");
} else {
a();
console.log(pro);
return pro;
}
}
pro(r);
}
if you change it like this, you will report an error.
console can get pro, want to know why thank you