1
How I would transform the following function using async/await?
const delay = () => new Promise(resolve => setTimetout(resolve, 1000);
function umPorSegundo() {
delay().then(() => {
console.log('1s');
delay().then(() => {
console.log('2s');
delay().then(() => {
console.log('3s');
});
});
});
}
umPorSegundo();
I know it would be something like this:
const delay = () => new Promise(resolve => setTimeout(resolve, 1000));
async function umPorSegundo(){
console.log(await delay());
console.log(await delay());
console.log(await delay());
}
umPorSegundo();
However, I don’t know how to pass a different string to each await.
That’s it! That’s what I really needed, thank you very much!
– Cyb3rz