DAY 4
opretor in javascript
comparison opratore
= - assionment opretore
== - comparision opretore or equality oprator
explame : 10 = = 10 //true
"10" == 10//true .beacause in javascript only check the value only not a datatype
"10" ==== 10//false . because if given the three equalse will also chenk the datatype also
next not equal !=
10 != 10 //false .beacuse will check the value is not equals or not but in this statument is equla
9 != 10 // true .
"10" !== 10 // true .because this check the type also
equlaent oprators:
==
===
!=
!==
comparision oprator
< - lessthan //find the number is small or not
> - greatthen // find the number is big or not
<= - lessthen or equalto
>= - greatthen or equalto
example:
7 < 10 // true // because 7 is small then to 10
7 >10 // false // because 7 is not bigerthen 10
10 < 10 // false // because 10 is not small or then 10
10 <= 10 //true // becaues 10 is small then or equal to 10 so true
10 > 10 //false // because 10 not bigerthen 10
10 >= 10 // true // because 10 is bigerthen or equal to 10 so true
logical operator:
AND - $$
OR - ||
NOT - !
AND GATE
if using AND gate the both of the two side is equal then only true
example : 10<7 && 10<6 //true && true
OR GATE
IF using OR gate any one of the side is true is the condision is true
example : 10<6 || 10>6 true || false
//AND gate
let ram =8;
let rom = 128;
if (ram>=8 && rom >= 128)
{
console.log("buy");
}//output : buy
//OR GATE //it also ram and rom
let raam = 6;
let room = 128;
if(raam >= 8 || room >= 128)//false || true
{
console.log("take")
} // output : take
//CONDISION IS FALSE IN THE CODE SO NO OUTPUT
// let i = 5;
// let j = 4;
// if(--i>j && i++ >=j--)//(4 > 4 && 5 >= 3)
// {
// console.log("true")
// console.log(i)
// console.log(j)
// }//not given the output
//CONDICTION TRUE IN THE OUTPUT
let k =5;
let m = 4;
if(--k>m || k++ >=m--)//(4 > 4 || 5 >= 3)
{
console.log(k);
console.log(m);
console.log("code done");
}
//output 5 - 3 - code done
//condiction if parchaes value is greaterthan or erqual to 1000Rs then you get discount
let perchesvalue = 1000;
if (perchesvalue >= 1000)
{
console.log('10% discount')
}
else{
console.log("no discount")
}
NO DISCOUNT CODE
let prodectvalue = 100;
if(prodectvalue >= 1000)
{
console.log('discount')
}
else{
console.log ("No discount")
}// OUTPUT : NO Discount
//task student take 50 and pass mark is above 50 is pass or below 50 is fail
let studentmark= 50;
if (studentmark>=50)
{
console.log("pass")
}
else{
console.log("fail")
}
//task if the student get a 90% mark will given A- great and if student taking 75% mark will get B -great
studentsmark = 98;
if(studentsmark>=50){
if(studentsmark >=90)
{
console.log("GREAT - A")
}
else{
console.log("GREAT -B")
}
}
else{
console.log("fales")
}//output: great -A
Top comments (0)