se mais JS
if (condition) {
// statement
} else if(condition){
// statement
}else{
// statement
}
CodePadding
if (condition) {
// statement
} else if(condition){
// statement
}else{
// statement
}
const count = 20;
if (count === 0) {
console.log('There are no students');
} else if (count === 1) {
console.log('There is only one student');
} else {
console.log(`There are ${count} students`);
}
Conditional (ternary) operator
condition ? exprIfTrue : exprIfFalse
if ((age >= 14) && (age < 19)) { // logical condition
status = "Eligible."; // executed if condition is true
} else { // else block is optional
status = "Not eligible."; // executed if condition is false
}