if (5 < 10) {
console.log("5 is less than 10");
} else {
console.log("5 is now bigger than 10")
}
if (condition) {
// statement
} else if(condition){
// statement
}else{
// statement
}
/*OR*/
condition ? statement(true) : statement(false) // Ternary operator
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");
}
var x = 1;
if(x==1)
{
console.log("x equals to 1")
}
else
{
console.log("x is not equal to 1");
}
const count = 20;
if (count === 0) {
console.log('There are no students');
} else if (count === 1) {
console.log('There is only one student');
} else {
console.log(`There are ${count} students`);
}
if( condition ) {
// ...
} else {
// ...
}
Code language: JavaScript (javascript)
const number = (Math.random() - 2.5) * 5;
if (number < 0) {
console.log('Number is negative');
}
if (number = 0) {
console.log('Number is zero');
}
if (number > 0) {
console.log('Number is positive');
}
if (a > 0) {
result = 'positive';
} else {
result = 'NOT positive';
}
if (condition) {
//what is done
}
if (condition){
// if true then execute this -}
else{
// if statment is not true then execut this -
}
if (condition)
statement1
// With an else clause
if (condition)
statement1
else
mein beispiel
if (32 == 32) {
console.log('32 is equil to 32!');
}
//loops If statement
if(loop < 12;) {
loops++
}
//if(args[0] === "hi"){
// console.log("Hello!");
//}
else {
//Your code here
}
if(){ //Note, you cant leave if() empty. You have to put something in it, for exmaple, if(args[0] === "hi")
//Your code here
}
if (!condition)
statement1
// With an else clause
if (condition)
statement1
else
statement2
if (person.age >= 16) { person.driver = 'Yes';} else { person.driver = 'No';}
If - Else Statements
if (condition) {
// what to do if condition is met
} else {
// what to do if condition is not met
}