Start (Copy 19319)
✨ Apichet Komwatcharapong
<h2>JavaScript async / await</h2> <h1 id="demo"></h1> <script> const h = document.getElementById("demo"); async function myDisplay(text, timeout) { return new Promise((resolve) => { setTimeout(() => { resolve(text); }, timeout); }) } const run = async () => { h.innerHTML += await myDisplay('1', 1000);; h.innerHTML += await myDisplay('2', 500);; h.innerHTML += await myDisplay('3', 100);; } run(); </script>