Press "Enter" to skip to content

Sample Addition Example in JavaScript

Last updated on October 5, 2019

Program :

<html>

  <head>

    <script type=”text/javascript”>

                  function display()

                  {

                  a=parseInt(prompt(“Enter A value”));

                  b=parseInt(prompt(“Enter B value”));

                  if(confirm(“Do you want addition?”))

                  {

                  c=a+b;

                  alert(“sum=”+c);

                  }

                  else

                  {

                  alert(“thank you”);

                  }

                  }

                </script>

  </head>

    <body>

                  <input type=”button” value=”First button” onclick=”display()”/>

                </body>

</html>

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *