Script – 22-55 Feb 1
I'm trying to run the function till
b.length === 1
and then return b
What am I doing wrong? it returns undefined
30 Replies
because you don't return
recall(b)
call?wow you could probably stand to name your variables a bit better 🙂
Like ![thistbh](https://cdn.discordapp.com/emojis/871942722003533904.png)
![thistbh](https://cdn.discordapp.com/emojis/871942722003533904.png)
i meant this
![](https://cdn.answeroverflow.com/938207510152769546/unknown.png)
😂
I was just rushing and giving it similar var names
I tried that but still got undefined
is
b.length === 1
condition ever met?yes
so
recall
at that case should return non-undefined b
variable, because it surely is array/string with length property equal to 1I'll look at my code ![yy](https://cdn.discordapp.com/emojis/230122396923723777.png)
![yy](https://cdn.discordapp.com/emojis/230122396923723777.png)
to be clear, you mean that
superDigit
returns undefined or recall
?
and are you sure that recursion ends sometime, not throws call stack exceeded error?Return the last line
return recall(b)
@ScriptOkay so I am finally exceeding the call stack
How do I manage this
Yeah then your base condition is never being met
It is actually
b becomes 3
that's length of 1
If you would properly hit the base condition you wouldn’t exceed the call stack
Are you calling length on a number? Does that give you the amount of digits?