Let’s say I have 4 functions, every each of them has loops inside working with setTimeout(). How do I make those functions to run in sequence and not overlap? That is, how do I make each of them execute just after previous one is finished?
function1();
function2();
function3();
function4();
Have each function call the next one after they’re done.
If you want to make it “dynamic”, implement a queue of functions and have each function call the next function in the queue when they’re done. Then you can start a sequenced process by filling the queue and calling the first function.