Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

How to display JavaScript variable value in alert box?



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>
Updated on: 2020-06-16T13:14:18+05:30

8K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements