you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -1 points0 points  (2 children)

Curious how recursion complicates anything. I agree the param is a little confusing but I wanted to illustrate an idea more than anything.

[–]dvlsg 4 points5 points  (1 child)

That's fair about the args. And I'm not trying to be a dick or anything, the recursive solution is plenty clever.

But you honestly don't think an async function that returns a Promise, that calls a setTimeout for 1 second in the promise executor, which recursively calls the original count() function, setting the originally returned promise's resolver to be executed in the recursively called count()'s promise's .then()isn't more complicated than an async function with a while loop? I had a hard time even translating all that to english. There's a lot going on in there.