I know its a very beginner question Here is scenario
Let number = 5;
number - 1;
console.log(number);
it shows 5, why it does not show 4;
I want to understand this below recursion. Here times-1
is passed each time function is called. How it reaches to zero? And how each time decremented value is passed.
if(times < 0)
return "";
if(times === 1)
return string;
else
return string + repeatStringNumTimes(string, times - 1);
}
repeatStringNumTimes("abc", 3);```
Aucun commentaire:
Enregistrer un commentaire