else if statement code example
Example 1: js if else
If - Else Statements
if (condition) {
} else {
}
Example 2: html if else statement example
<div *ngIf="!show">
<div>show is false</div>
</div>
<div *ngIf="show">
<div>show is ture</div>
</div>
Example 3: IF else statement
var age=20;
if (age < 18) {
console.log("underage");
} else {
console.log("let em in!");
}
Example 4: IF else statement
var age=20;
if (age < 18) {
console.log("underage");
} else {
console.log("let em in!");
}
Example 5: JavaScript if else and else if
if (condition) {
}
if (hour < 18) {
greeting = "Good day";
}
if (condition) {
} else {
}
if (hour < 18) {
greeting = "Good day";
} else {
greeting = "Good evening";
}
if (time < 10) {
greeting = "Good morning";
} else if (time < 20) {
greeting = "Good day";
} else {
greeting = "Good evening";
}
Example 6: if statement
if( name = 'george washington'):
print("You have the same name as the first president of the United States")
else:
print("You do not have the same name as George Washington")