JavaScript Alert Box

JavaScript Alert Box

Alert Box

is actually to display a message or value, you can perform arithmetic operation, condition etc,

Example1:

<!DOCTYPE html>
<html>
 <body>
  <script>
  alert(" Welcome to JavaScript");
  </script>
 </body>
</html>

Output : Welcome to JavaScript

Example2:

<!DOCTYPE html>
<html>
 <body>
  <script>
  var a=10;
  var b=20;
  alert(a+b);
  </script>
 </body>
</html>

Output: 30

Exampl3:

<!DOCTYPE html>
<html>
 <body>
  <script>
  var a=10;
  var b=20;
  var c=a+b;
  alert(c);
  </script>
 </body>
</html>

Output: 30

Example4:

<!DOCTYPE html>
<html>
 <body>
  <script>
   var a=10;
   var b=20;
   if(a>b)
   {
   alert(" a is greater ");
   }
   else
   {
   alert("b is greater");
   }
  </script>
 </body>
</html>

Output: b is greater