Conditional Statements - Part 3

Notes:

JavaScript else if ladder statement:
else if ladder helps us to check multiple conditional expressions
looks like a ladder

syntax:
if(conditional expression1)
{
statements; // true part for if (conditional expression 1)
}
else if(conditional expression2)
{
statements; // true part for if (conditional expression 2)
}
else if(conditional expression3)
{
statements; // true part for if (conditional expression 3)
}

else
{
statements; // false part if no conditional expression evaluates to true
}

Example Code:
var marks = 200;
if((marks>=0) && (marks<30)){
document.write("Fail");
}
else if((marks>=30) && (marks<50)){
document.write("C grade");
}
else if((marks>=50) && (marks<60)){
document.write("B grade");
}
else if((marks>=60) && (marks<70)){
document.write("A grade");
}
else if((marks>=70) && (marks<=100)){
document.write("A+ grade");
}
else{
document.write("invalid marks");
}

Interview Questions: