JavaScript Control Structures
Control statement or control structure are used to manage program execute is based on specific condition. In this section are given basic example which are control program execution dynamically. That is very important because there is possible a simple app are based on multiple test condition.
If Else Statement
That is simple and selection based statement that is depending upon given expression condition. Generally most of statements are based on condition, because condition is decide the which statements allowed to the current execution. if-statement are defined by given syntax.
if(expression){
//when expression is true
}
Nested if-else statements
if(condition){
if(otherCondition){
if(someCondition){
//condition code
}
}
if(condition){
}
}
Switch case
switch statement are used to check multiple test condition of a particular variable value.
var data =10;
var five=5,seven=7,ten=10;
switch(data){
case five:
console.log("Five");
break;
case seven:
console.log("Seven");
break;
case ten:
console.log("Ten");
break;
default:
console.log("That is default");
}
Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.
New Comment