Conditional statements let your program make decisions. JavaScript provides if, else if, and else for branching logic.
if (condition) {
// runs when condition is true
} else if (anotherCondition) {
// runs when first was false but this is true
} else {
// runs when none of the above matched
}
For a simple true/false choice:
let age = 20;
let status = age >= 18 ? "adult" : "minor";
getGrade(score) that returns a letter grade:
"A" for score ≥ 90"B" for score ≥ 80"C" for score ≥ 70"D" for score ≥ 60"F" for anything below 60getGrade(85) and display the result in #output as "Grade: B".Use if (score >= 90) to check for grade A.