We can use the switch statement to select a particular group of statement to be executed among several other groups of statements. Now here We create a Web Page named SwitchStatemet.html which shows the use of the switch statement.
####Showing the code for the SwitchStatement.html #####
<!DOCTYPE html>
<head>
<title>Using Switch Statement </title>
</head>
<body background="img.jpeg" text="green">
<h1>Using switch Statement in the script </h1>
<SCRIPT type="text/javascript">
var letter="I"
switch(letter)
{
case "A":document.write("A is a vowel");
break;
case "E":document.write("E is a vowel");
break;
case "I":document.write("I is a vowel");
break;
case "O":document.write("O is a vowel");
break;
case "U":document.write("U is a vowel");
break;
default:document.write("consonant");
break;
}
document.write("<br/>THANK you So Much!!!!!");
</SCRIPT>
</body>
</html>
The letter variable is the expression for the switch statement. The value of the letter variable is compared with the case values one by one. When a match is found which in this case is the third case statement the set of statement specified in that case statement is executed.
#####Showing the output of SwitchStatement.html file#####
####Showing the code for the SwitchStatement.html #####
<!DOCTYPE html>
<head>
<title>Using Switch Statement </title>
</head>
<body background="img.jpeg" text="green">
<h1>Using switch Statement in the script </h1>
<SCRIPT type="text/javascript">
var letter="I"
switch(letter)
{
case "A":document.write("A is a vowel");
break;
case "E":document.write("E is a vowel");
break;
case "I":document.write("I is a vowel");
break;
case "O":document.write("O is a vowel");
break;
case "U":document.write("U is a vowel");
break;
default:document.write("consonant");
break;
}
document.write("<br/>THANK you So Much!!!!!");
</SCRIPT>
</body>
</html>
The letter variable is the expression for the switch statement. The value of the letter variable is compared with the case values one by one. When a match is found which in this case is the third case statement the set of statement specified in that case statement is executed.
#####Showing the output of SwitchStatement.html file#####
No comments:
Post a Comment