const hour = 21;
if (hour < 18) {
console.log('Deschis');
} else {
console.log('Închis');
}21 is not less than 18, so the else branch runs.
LESSON 19 OF 50
Use if…else for alternative outcomes.
if executes the first branch when the condition is true. else provides the branch used when that condition is false.
const hour = 21;
if (hour < 18) {
console.log('Deschis');
} else {
console.log('Închis');
}21 is not less than 18, so the else branch runs.
if (hour < 18) { console.log('Deschis'); }Without else, the false case produces no message.
Print “Deschis” before hour 18, otherwise “Închis”.
Run the code to see the result.One condition chooses between two mutually exclusive outcomes.
ANALYSIS REQUEST
The initial discussion is without obligation. You receive an honest recommendation, suitable stages and the factors that affect price.