Coder Baba
2.42K subscribers
1.01K photos
23 videos
722 files
723 links
Everything about programming for beginners.
1 and only official telegram channel of CODERBABA India.

Content:
.NET Developer,
Programming (ASP. NET, VB. NET, C#, SQL Server),
& Projects
follow me https://linktr.ee/coderbaba
*Programming
*Coding
*Note
Download Telegram
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>
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
coderbabafashionPro2 - Copy.rar
8 MB
03 Mini Project asp.net Online Shopping website source code