Here is the version of a sleep() function using an async function:
sleep()
javascriptawait new Promise(r => setTimeout(r, 1000))
await new Promise(r => setTimeout(r, 1000))
Props to the author.
Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.