let a = 1;
let b = 2;
if(a == 1 && b ==2){//this symbol is for AND
// Code here
}
let a = 1;
let b = 2;
if(a == 1 || b ==2){//this symbol is for OR
// Code here
}
let a = 1;
let b = 2;
if(a == 1 && b ==2){
// Code here
}
if (5 < 10) {
console.log("5 is less than 10");
} else {
console.log("5 is now bigger than 10")
}
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 -
}
function LetterCapitalize(str) {
var output = ""+str.charAt(0).toUpperCase();
for(var i=1; i < str.length; i++){
if(str.charAt(i - 1) == " ") {
output += str.charAt(i).toUpperCase();
} else {
output += str.charAt(i);
}
}
return output;
}
console.log(LetterCapitalize("hello world"))
if (32 == 32) {
console.log('32 is equil to 32!');
}
//loops If statement
if(loop < 12;) {
loops++
}
If - Else Statements
if (condition) {
// what to do if condition is met
} else {
// what to do if condition is not met
}