JAVASCRIPT Tutorial
// if the age is less than 18, print "You are not old enough."
if (age < 18) {
console.log("You are not old enough.");
}
// otherwise, print "You are old enough."
else {
console.log("You are old enough.");
}
if
block is only executed if the condition is true.else
block is executed only if the condition is false.else
block is optional, but the if
block is not.else if
statements can be chained after the if
statement to check multiple conditions.