Skip to content

Instantly share code, notes, and snippets.

@chinchang
Created November 9, 2019 07:50
Show Gist options
  • Save chinchang/7e7cf9dc31b41f98d06ef5ac24b43a4d to your computer and use it in GitHub Desktop.
Save chinchang/7e7cf9dc31b41f98d06ef5ac24b43a4d to your computer and use it in GitHub Desktop.
async function loop() {
for (let i = 0; i < 10; i++) {
document.body.innerHTML += i + " ";
await waitForEvent();
}
}
function waitForEvent() {
return new Promise(resolve => {
window.onclick = () => {
console.log("clicked");
resolve();
};
});
}
loop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment