Colo
0
Q:

if statement

if (condition)
{
     //Block of statements here
     //These statements will only execute if the condition is true
}
 else {
	//Write the else condition
}
5
if( name = 'george washington'):
	print("You have the same name as the first president of the United States")
    // python 
else:
	print("You do not have the same name as George Washington")
4
var age=20;
if (age < 18) {
	console.log("underage");
} else {
	console.log("let em in!");
}
27
if (condition) {
  //  block of code to be executed if the condition is true
 } else {
  //  block of code to be executed if the condition is false 
 }

//example
var money = 200;
var price = 159;

if (money >= price) {	//if money is higher or equal to price
  alert("you have enough money")
} else {
  alert("you don't have enough money")
}


// you can add another condition to the else
if (age < 18) {
  alert("too young")
} else if (age > 80) {
  alert("too old")
}
1

if (hour < 18) {

    greeting = "Good day";

 }
else {

    greeting = "Good evening";

 }
 
5
if (condition a) {
    // code that will execute if condition a is true
} else if (condition b) {
    // code that will execute if condition b is true
} else if (condition c) {
    // code that will execute if condition c is true
} else {
    // code that will execute if all above conditions are false
}
0
if (A === B) && B === 1) {
  // Code here
}
0
if (X < 10) {
 print "Hello John";
}
0

if (hour < 18) {

    greeting = "Good day";

 } 
4

New to Communities?

Join the community