Alan He
1 min readJul 21, 2020

--

you can use promise chain,just like this

```

const waitFor = (ms) => new Promise((r) => setTimeout(r, ms));

const start = () => {

let next = Promise.resolve();

for (const element of array) {

next = next.then(() => waitFor(1000)).then(() => console.log(element));

}

next.then(() => console.log('done'));

};

start();

```

--

--