if else loops
Shubhendu Jadhav
1 min read
console.log("hello wrold");
let a=5;
a++;
a--;
console.log(a);
let b=2;
console.log("a=",a,"&b=",b);
console.log("a+b=",a+b);
console.log("a-b=",a-b);
console.log("a*b=",a*b);
console.log("a/b=",a/b);
console.log("a%b=",a%b);
a!==b;
console.log("a!==b",a!==b);
let cond1=a>b;
let codn2= a===6;//=== (Strict Equality):checks if the two variables
//are equal or not
console.log("cond1&&cpnd2",codn2&&cond1);
let c=7;
let d=8;
console.log("c>d",!(c>d));//logical not it revrese the deceion of the logical operators
///////////condtionl statemnets
let age=11;
if(age>=18){
console.log("you can vote");
}
if(age<18){
console.log("you can not vote");
}
/// you can use many if loops it wwill check the condtion
//and it will give the answer
let mode="light";
let color;
if(mode==="daak"){
color="black";
}
if(mode==="light"){
color="white";
}
console.log(color);
/////////////////////////////
//////if else condtion/////and elseif lops/////
let mode1 ="blue";
if(mode1==="white"){
color="white";
}
else if(mode1==="blue"){
color="black";
}
else{
color="blue";
}
console.log(color);
////////////ternary operator////////
let sam_age=34;
let result =sam_age>=18? console.log("adult"): console.log("not adult");
alert("hello");
let nam =prompt("enter the number");
if(nam%3===0){
console.log(nam,"divisible by 3");
}
else{
console.log(nam,"not divisible by 3");
}
let score = prompt("Enter the score(0-100):");
if(score>=80 && score<=100){
console.log(score,"Your grade is: A");
}else if(score>=80 && score<=89){
console.log(score,"Your grade is:B");
}else if(score>=60 && score<=69){
console.log(score,"Your grade is:C");
}else if(score>=50 && score<=59){
console.log(score,"Your grade is:D");
}else {
console.log("abhys kar lavdya")
}
//comparisons in any coding language are just boolean operations
//they give values in either true or false so if u have to comapre two operations
//use && ,|| logical gates which will comapre these answers and give the answers.
0
Subscribe to my newsletter
Read articles from Shubhendu Jadhav directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by