JavaScript Program to Display Alert After Few Seconds

Write a JavaScript program to display alert after few seconds.



Source Code
<html>
<head>
    <title>Display Alert After 3 Few Seconds</title>
    <script>
        var myVar;

        function myFunction() 
        {
            myVar = setTimeout(alertFunc, 3000);
        }

        function alertFunc() 
        {
            alert("Good Bye!");
        }
    </script>
</head>
<body>

<p>Click the button to wait 3 seconds and see the magic</p>

<button onclick="myFunction()">Click Me</button>

</body>
</html>
Output