CONDITIONAL STATEMENT
In JavaScript Conditional statement is used to make a decision in program. It will execute the flow of program whether the condition is true means it return TRUE otherwise it return FALSE.
Conditional statement is work on comparison and logical operator
There are some types of Conditional Statements like [if, else if]
- IF- STATEMENT
In JavaScript, the if statement executes a block of code only if a specified condition evaluates to true. Use the else statement to specify a block of code to be executed if a condition is false.
let mark=32
if (mark>=35){
console.log("pass")
}else{
console.log("fail")
}
output: fail
- ELSE IF - STATEMENT
In JavaScript the Else if condition is a new condition it execute when the first condition is false .
let mark =78
if(mark>=90){
console.log("A")
}
else if (mark>=75)
{
console.log("B")
}
else if (mark>=50){
console.log("C")
}
else{
console.log("fail")
}
output : B
Top comments (0)