When you want a series of events to start one after another, recursion is your best bet.
In your code all the loop iterations happen right away, as do the ifs.
You could use a normal for loop if you delayed each if inside a setTimeout call.
- for (var i = 0, limit = 5; i < limit; i++){
- setTimeout(… , i*5000)
- }
I was born thinking recursively. It's just the way I was wired.
JΛ̊KE