Conditional Statements
Types
- if(logical test){ block of code}
- if(logical test){
Block of code
}else{
Alternate block of code
}
- if(logical test){
Block of code
}elseif(alternate logical test){
Block of code
}else{
Catch all block of code
}
1 TRUE: a and b = 13
2 FALSE: a and b equals 13
3 FALSE: a and b equals 13
Switch statement
- switch (n) {
case label1:
code to be executed if n=label1;
break;
case label2:
code to be executed if n=label2;
break;
case label3:
code to be executed if n=label3;
break;
...
default:
code to be executed if n is different from all labels;
}
the colour isn't one of the options: red, green or blue Simple if statements
The value of a is less than b
Check the existance of a variable
The variable c does not exist or is not set.