if else javascript syntax 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;
if (condition == true) {
console.log('condition is true');
} else {
console.log('condition is not true');
}
Example 3: how to make an if statement in javascript
if(condition1) {
}else if (condition2) {
} else {
}
Example 4: if statements javascript
if (pros < 10) {
console.log("LESS THAN 10 PROS!");
}
else if (pros < 5) {
console.log("LESS THAN 5 PROS!");
}
else {
console.log("How many pros are there?");
}
Example 5: else if
if ( x > 10 )
{
cout << "x is greater than 10";
}
else
{
cout << "x is less than 10";
}