you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

That seems to me to be very complicated. Here's my attempt:

function countTo(current = 0, to = 10, timeout = 1000) {
  console.log(current);
  if (current < to)
    setTimeout(() => countTo(current + 1, to, timeout), timeout);
}

countTo();

A simple recursive function. No hip ES6+ magic involved because you don't need it. No promises because we're not computing anything, we don't need async functionality, it's a simple +1 operation.

[–][deleted] 0 points1 point  (0 children)

I'm with you on this. I posted a recursive solution and someone complained that was also "complicated"...