May 2019
Intermediate to advanced
546 pages
12h 41m
English
Conditional statements (better known as if-else statements) execute code in certain circumstances. You can use these types of statements when you need to execute code when a variable has a certain value. The syntax of a conditional statement is as follows:
If (Boolean_Condition){ // Execute code block }
You can also execute default code in an if statement. For instance, if a variable has a certain value, execute block 1; in all other circumstances, execute block 2:
If (Boolean_Condition){ // Execute code block 1} else { // Execute code block 2}
You can also add several conditions when you need to execute the code:
If (Boolean_Condition){ // Execute code block 1} else if (Another_Boolean_Condition){ // Execute code ...Read now
Unlock full access