Conditionals and Logic
Chained Conditions
Check several conditions in order.
Chained Conditions
chained_conditions.js
const points = 85;
let grade = "";
if (points >= 90) {
grade = "A";
} else if (points >= 70) {
grade = "B";
} else {
grade = "C";
}
console.log("points=" + points);
console.log("grade=" + grade);
chained-conditions
An `else if` chain tests conditions from top to bottom and stops at the first matching branch.