if else condition in nodejs code example
Example 1: IF else statement
var age=20;
if (age < 18) {
console.log("underage");
} else {
console.log("let em in!");
}
Example 2: how to use if else statement in javascript
var condition = true; // An example condition for true/false conditions
if (condition == true) {
console.log('condition is true');
} else {
console.log('condition is not true');
} // Console will output 'condition is true'
Example 3: if statement javascript
const randomObject = 5;
if(randomObject < 2) {
console.log("The Random Object has a value more than 2");
}
else {
console.log("The Random Object has a value less than 2");
}