Question :1
What is switch statement and define its rules and explain with Example in Javascript.
Ans:
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case.
Syntax:
----------------------------------
switch(expression) {
case expression :
statement1;
break; /* optional */
case expression :
statement2;
break; /* optional */
/* you can have any number of case statements */
default : /* Optional */
statement3;
}
------------------------------
The following rules apply to a switch statement :−
1-: You can have any number of case statements within a switch. Each case is followed by the value to be compared to and a colon.
2-: The expression for a case must be the same data type as the variable in the switch.
3-: When the variable being switched on is equal to a case, the statements following that case will execute until a break statement is reached.
4-: When a break statement is reached, the switch terminates, and the flow of control jumps to the next line following the switch statement.
5-: Not every case needs to contain a break. If no break appears, the flow of control will fall through to subsequent cases until a break is reached.
6-: A switch statement can have an optional default case, which must appear at the end of the switch. The default case can be used for performing a task when none of the cases is true. No break is needed in the default case.
-----------
Example:
<script>
var grade = 'B';
switch(grade) {
case 'A' :
alert("Excellent!\n" );
break;
case 'B' :
case 'C' :
alert("Well done\n" );
break;
case 'D' :
alert("You passed\n" );
break;
case 'F' :
alert("Better try again\n" );
break;
default :
alert("Invalid grade\n" );
}
</script>
What is switch statement and define its rules and explain with Example in Javascript.
Ans:
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case.
Syntax:
----------------------------------
switch(expression) {
case expression :
statement1;
break; /* optional */
case expression :
statement2;
break; /* optional */
/* you can have any number of case statements */
default : /* Optional */
statement3;
}
------------------------------
The following rules apply to a switch statement :−
1-: You can have any number of case statements within a switch. Each case is followed by the value to be compared to and a colon.
2-: The expression for a case must be the same data type as the variable in the switch.
3-: When the variable being switched on is equal to a case, the statements following that case will execute until a break statement is reached.
4-: When a break statement is reached, the switch terminates, and the flow of control jumps to the next line following the switch statement.
5-: Not every case needs to contain a break. If no break appears, the flow of control will fall through to subsequent cases until a break is reached.
6-: A switch statement can have an optional default case, which must appear at the end of the switch. The default case can be used for performing a task when none of the cases is true. No break is needed in the default case.
-----------
Example:
<script>
var grade = 'B';
switch(grade) {
case 'A' :
alert("Excellent!\n" );
break;
case 'B' :
case 'C' :
alert("Well done\n" );
break;
case 'D' :
alert("You passed\n" );
break;
case 'F' :
alert("Better try again\n" );
break;
default :
alert("Invalid grade\n" );
}
</script>
HTML MetaData notes.docx
297.4 KB
Hey everyone here i am sharing my own study Material which is related to HTML <Meta> tag
A to Z about Meta tag & Metadata ...
i hope you guys are love it....
dont forget to share & supscribe #CODERBABA
A to Z about Meta tag & Metadata ...
i hope you guys are love it....
dont forget to share & supscribe #CODERBABA
watch New Video
Mini Project Shopping website Part-3
how to add quantity and report page
video Link:
https://youtu.be/Vdo1rmvCD9s
do Like share Subscribe
Mini Project Shopping website Part-3
how to add quantity and report page
video Link:
https://youtu.be/Vdo1rmvCD9s
do Like share Subscribe
YouTube
03 Mini Project | Online Shopping Website | ASP.NET C# | SQL SERVER | CODERBABA | In HINDI
03 Mini Project | #OnlineShoppingWebsite | ASP.NET C# | SQL SERVER | #CODERBABA | the language of video is In HINDI.
in this video you will learn how to create "Add Quantity" and "Report" webpages.
join Telegram: https://t.me/coder_baba
...........................…
in this video you will learn how to create "Add Quantity" and "Report" webpages.
join Telegram: https://t.me/coder_baba
...........................…
coderbabafashionPro2 - Copy.rar
8 MB
03 Mini Project asp.net Online Shopping website source code
New modified Eshopping Website with add to cart multiple products
Video out today:
https://youtu.be/Dx5IiZstC9I
Video out today:
https://youtu.be/Dx5IiZstC9I
YouTube
New E Shopping Website ASP.NET C# Project (Modified) | Final Year Project | coderbaba
E-Shopping Website asp.net C# project with source code and SQL Server database.
Download Source code: https://bit.ly/3sB9QJT
E Shopping Website Password Recovery gmail Error Solution in asp.net C#
Watch: https://youtu.be/VqBnePijFnw
instamojo…
Download Source code: https://bit.ly/3sB9QJT
E Shopping Website Password Recovery gmail Error Solution in asp.net C#
Watch: https://youtu.be/VqBnePijFnw
instamojo…