javascript if inside else if code example
Example 1: 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 2: how to use if else statement in javascript
var condition = true;
if (condition == true) {
console.log('condition is true');
} else {
console.log('condition is not true');
}