Conditionals and Logic
If Else Logic
Choose one of two branches with an if/else statement.
If Else Logic
if_else_logic.js
const temperature = 72;
let label = "";
if (temperature >= 70) {
label = "warm";
} else {
label = "cool";
}
console.log("temperature=" + temperature);
console.log("label=" + label);
if-else
An `if` statement runs its first branch when the condition is true. Otherwise, the `else` branch runs.