delay()

How to made delay function

js

const delay = (ms) => {
    return new Promise((resolve) => {
        setTimeout(resolve, ms)
    })
}

How to use

js

await delay(1000);
console.log("1 sec")
await delay(1000);
console.log("2 sec")