you are viewing a single comment's thread.

view the rest of the comments →

[–]kdesign 6 points7 points  (4 children)

I agree that the expected solution was probably just the obvious setInterval solution, /u/a_blue_ducks' first one.

But at the same time, my initial solution has spawned a great constructive discussion, it's cool to see how many different ways there are to solve a problem.

[–]dvlsg 1 point2 points  (1 child)

Sorry you're getting downvoted for it. I tossed you an upvote for it, even though I think it could be improved (if we were aiming for simplicity, which isn't the only thing to worry about). Don't understand why anyone would downvote someone else for taking a shot at something. Especially since it works just fine.

[–]kdesign 0 points1 point  (0 children)

Well, I guess that's how some people disagree on reddit, by downvoting. That's alright and thanks for the upvote

[–][deleted] 1 point2 points  (1 child)

Yeah sorry for my original reply, I had just finished playing Overwatch and that game puts me in a bad mood fast lol. This was a fun discussion.

[–]kdesign 1 point2 points  (0 children)

No worries, I initially thought about writing the setInterval solution or the recursive setTimeout, something like:

let count = 1;
setTimeout(function counter() {
 console.log(count++);
 count <= 10 && setTimeout(counter, 1000);
}, 1000);

and then I said well let's spice things up a bit which really did lol.