×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Jason code
Added: Mar 28, 2021 1:41 AM
Views: 4339
Tags: no tags
  1. for (let i = 0; i < 10; i++) {
  2.     const promise = new Promise((resolve, reject) => {
  3.         const timeout = Math.random() * 1000;
  4.         setTimeout(() => {
  5.             console.log(i);
  6.         }, timeout);
  7.     });
  8.  
  9.     // TODO: Chain this promise to the previous one (maybe without having it running?)
  10. }