if then statements javascript code example

Example 1: js if else

If - Else Statements
if (condition) {
// what to do if condition is met
} else {
// what to do if condition is not met
}

Example 2: if else javascript

if (time < 10) {
  greeting = "Good morning";
} else if (time < 20) {
  greeting = "Good day";
} else {
  greeting = "Good evening";
}

Example 3: using if statements in javascript

if (expression) {
   Statement(s) to be executed if expression is true
} else {
   Statement(s) to be executed if expression is false
}

Example 4: javascript if else

var age=20;
if (age < 18) {
	console.log("underage");
} else {
	console.log("let em in!");
}

Example 5: javascript if statement

if (5 < 10) {
	console.log("5 is less than 10");
} else {
	console.log("5 is now bigger than 10")
}

Example 6: if then else

if then else

Tags:

C Example