In the recursive version, JavaScript produces SyntaxError(It would be nice if it wouldn't) cause ternary operator does not allow spreading like this. We can solve it using spread operators if we really want to, but I've found concat requires a little less typing:
.reduce
or an equivalent.Then, for a more complex version.
In the recursive version, JavaScript produces SyntaxError(It would be nice if it wouldn't) cause ternary operator does not allow spreading like this. We can solve it using spread operators if we really want to, but I've found
concat
requires a little less typing:Thanks for reading the post and for another solution. I just wanted to cover use cases of recursion.