function reverse(str){
if(str.length <= 1) {
return str;
}
return reverse(str.slice(1)) + str[0];
}
console.log(reverse("two"))
When the last return str line hits inside the if statement, it returns 'o'. Yet there is an extra + str[0] outside the if statement. Shouldn't it be returning 'oo' rather than 'o'?
The function is working completely fine, but when I try to visualize it I get confused.
