Logical Operator

Operator Name Conditions
&& Logical AND dfdf
|| Logical OR (Pai) dfdf
! Logical NOT dfdf

if conditions are used to run any statement.

Statement does not run until unless condition get true.

Logical operators are used if we need to check more than 1 condition in any statement.

If (condition1 && condition2){
}

&& = If both condition are true then the statement will run
If any condition is false then code will not run

If (condition1 || condition2){
}

|| If any one condition is incorrect code statement will run.

<script>
var age="18";
if(age >=18 && age<= 18){
document.write("Yes you are eligible")
}
</script>

 

Following is another code example of Logical OR ||

<script>
var jan= 5000;
var feb = 9000;
var march = 6000;
if(jan >= 4000 && feb >= "5000" && march >="8000" ){
document.write("Yes you are eligible")
}
else{
window.alert("you are not eligible")
};
</script>

dfdff