Conditional statements allows us to perform various different operations for different conditions. It run different code depending on true or false conditions.
It includes;
if statement
if.. else.. statement
if.. else if.. else.. statement
switch statement
ternary
If statement
"if" statement is used when specific code needs to executed if the given conditions is true.
Syntax:
if (condition == true){
/execute the block of code/
}
If.. else.. statement
"If.. else" statement, if used when given condition is true and block is executed. And, else is used when given condition is false.
Syntax:
if (condition == true){
/execute the block of code if condition is true/
} else{
/execute the block of code if condition is false/
}
similarly other statements also execute depending on true or false. In switch statement, it has multiple options...
Top comments (0)