JavaScript Program to Show Alert Message on Button Click

Write a JavaScript program to show alert message on button click.

Source Code

    <title>JavaScript event example</title>
    <script type="text/javascript">
        function sayHello() {
            alert("Hello World!")

    <p>Click the button to see result</p>
        <input type="button" onclick="sayHello()" value="Say Hello" />


"Coding Hub - Learn to code" app now available on Google Play Store