Last active
August 4, 2018 03:43
-
-
Save DannyFeliz/6b1a4ad3bc57b0cfb1c278aa8ba49dcc to your computer and use it in GitHub Desktop.
for loop with timeout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const timeoutList = [5000, 2500, 4500]; | |
async function initInterval() { | |
for(const timeout of timeoutList) { | |
await runTimeout(timeout); | |
} | |
} | |
function runTimeout(timeout) { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
console.log("Run =>", timeout); | |
resolve(); | |
}, timeout); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment