Sunday, 10 January 2021

Conditional Statement Using Java Script

 Java Script Conditional Statement

IF... ELSE Statement:

The if/else statement executes a block of code if a specified condition is true ther wise false.

Example: 
<script>
a= 10;
b =10;
if(a==b)
{
document.write("<h1>Avadh Tutor</h1>");
alert("All Programming languages ");
document.write("Thanks For Watch");
}
else
{
alert("Welcome to Avadh tutor");
}
if(a<b)
{
document.write("<h1>please Subscribe Our Blog</h1>");
alert("youtube.com/avadhtutor");
document.write("pandyaripal.blogspot.com");
}
else
{
alert("all programming are here");
}
if(a>b)
{
document.write("<h1>Greater then</h1>");
alert("True");
document.write("A is Small");
}
else
{
alert("abcd");
}
</script>

_____________________________________________________

IF ..... ELSE IF..... 

Example:

<script type="text/javascript">

var a=parseInt(prompt("Enter No A",""));


var b=parseInt(prompt("Enter No B",""));

if(a<b)

{

document.write("A Is Less Then Of 20 <br>");

}

else if(a==b)

{

document.write("A is equal to B <br>");

}

else if(a<50)

{

alert("hello");

}

else

{

alert("this is a alert box");

}

</script>

__________________________________________________________

Switch Statement using Java Script:

Example:

<script type=text/javascript>

var d=new Date();

abc=d.getDay();

a = parseInt(prompt("enter Switch",""));

switch (a)

{

default:

  alert("no case define");

break;

case 0:

document.write("Hello");

break;

case 1:

document.write("Monday");

break;

case 2:

  document.write("welcome");

  break;

case 3:

  document.write(" Tamene Game e rakho");

  break;

case 4:

  document.write("Sleepy THUS");

  break;

case 5:

  document.write("Sleepy FRI");

  break;

case 6:

alert("end of");

break;

}

</script> 

___________________________________________________________

Learn All programming and Scripting languages with youtube.com/avadhtutor/



1 comment: