Is there any way to know when a recursive function has stopped calling itself?
I have the following scenario:
function print(msg){
console.log(msg);
if(canContinue){
print("Hi there");
}
if(canContinueCase2){
setTimeout(()=>{
print("I was late to the party");
}, 2000);
}
if(canContinueCase3){
print("Cool right?");
}
if(canContinueCase4){
if(canContinueCase5 && !otherBoolean){
print("Thank you!");
}
}
}
canContinue, canContinueCase2, ... otherBoolean are global variables (booleans). How would one know when the function print(msg) is no longer being called? In other words how can I know that the algorithm has stopped?