Reputation: 21
How can I alternately perform 2 different functions
Example: Function 1 executed After 20 seconds function 2 executed and then everything starts again
Upvotes: 0
Views: 72
Reputation: 1813
function function1() {
// Do what you have to do...
console.log("Function 1 called");
setTimeout(function2, 20000);
}
function function2() {
// Do what you have to do...
console.log("Function 2 called");
setTimeout(function1, 20000);
}
function1();
Upvotes: 1