3
I have this asynchronous code:
const delay = () => new Promise(resolve => setTimeout(resolve, 1000));
async function umPorSegundo(){
console.log(await delay(), '1s')
console.log(await delay(), '2s')
console.log(await delay(), '3s')
}
umPorSegundo();
The delay
is done correctly, but the console always returns undefined
before. How to make it return only the seconds?
console.log(await delay() || '1s');
– vik