JS Async: 01. Callback: set timeout

by istiq20

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Callback: Set Timeout</title>
  </head>
  <body>
    <script>
      function addElement() {
        const header = document.createElement("h1");
        header.textContent = "Programmer Zaman Now";

        document.body.appendChild(header);
      }

      setTimeout(addElement, 5000);
      document.writeln("Program Selesai");
    </script>
  </body>
</html>