I tried to use async and await but it didn’t work because it runs in the background. I would like a way to make the entire script kinda sleep, like time.sleep in Python.
I tried using async and await with code looking like this:
const sleep = (delayInms) => {
return new Promise(resolve => setTimeout(resolve, delayInms));
};
async function Delay() {
console.log("0s");
await sleep(1000);
console.log("1s");
}
function main() {
Delay();
console.log("1s also")
}
I am working with HTML, CSS and JS. This resulted returning
1s also
in the console at the same time as
0s