How to display JavaScript variable value in alert box?

JavascriptWeb DevelopmentFront End Technology

To display JavaScript variable value in an alert box, try to run the following code −

Example

Live Demo

<html>
   <head>
      <script>
         function display() {
            var a = "Simple";
            var b = "Learning";
            alert(a +" Easy "+ b);
         }
      </script>
   </head>
   <body>
      <input type="button" value="Click me!" onClick="display();">
   </body>
</html>
raja
Published on 03-Feb-2018 10:00:33
Advertisements