hey y'all it's Ami so today I'm going to explain logical operators there's three of them and or not they're used to combine or manipulate Boolean values Boolean values if you remember are true or false let's create a program const temp meaning temperature what I would like to do is see if my temperature Falls within a certain range this will be in Celsius let's say the temperature is 28 degrees Celsius without using any logical operators let's write this if our temp is greater than zero then we will console DOT log the weather is good else if
the temperature is less than or equal to 30 30 degrees Celsius we will also output the weather is good else the weather is bad currently my temperature is 20 degrees Celsius the weather is good what if I were to change this to something ridiculous like 200 degrees Celsius well the weather is obviously not good Earth probably got hit by an asteroid or something or if I were to change my temperature to like negative 100 degrees Celsius while the weather isn't good either I don't know maybe the sun disappeared so what I want to do is
output the weather is good only if my temperature Falls between the range of 0 and 30. so we're going to change this program if our temperature is greater than zero and we'll check another condition and our temperature is greater than or equal to 30 then we can eliminate this else if clause now let's check the temperature our temperature is negative 100 degrees Celsius well the weather is bad if our temperature was 200 degrees Celsius the weather is also bad in order for us to execute this if statement both these conditions need to be true this
one and this one to join two conditions you use double Ampersand meaning and if our temperature was 25 well that falls within our range the weather is good this is true and this is true so we will execute this code if one of these was false we don't execute it at all we'll skip over it so that is the andological operator you can check more than one condition you can check one thing and something else now there's or which is double straight bars with the orological operator at least one of these conditions needs to be
true this has to be true or that has to be true if I were to run the same program well then the weather is good let's change the temperature to 250 the weather is good but it's not it shouldn't be so let's rewrite this program if our temp is less than or equal to zero or the temperature is greater than 30 then the weather is bad else the weather is good our temperature is 250 the weather is bad negative 250 the weather is also bad so with the or logical operator we're checking more than one
condition is this true yes it is negative 250 is less than zero or is this condition true this one is false but since at least one of these is true we will execute this code then we will cover the notchological operator let's create a new program const is sunny is it sunny outside this will be true or false we will create an if statement our condition will be is sunny isn't this true if it is we will console .log it is sunny else we will cancel that log it is cloudy is sunny is set to
true it is sunny If This Were false then it is cloudy using the not logical operator we can flip a Boolean from True to false or false to true I will precede this Boolean with the not logical operator which is an exclamation point now we're checking if it's not sunny then we will console.log it is cloudy else it is sunny is it not sunny outside it is cloudy let's change this to be true it is sunny so basically the not logical operator it'll change true to be false and false to be true alright everybody so
that's a short topic today logical operators they're used to combine or manipulate Boolean values use and to check to see if at least two conditions are true with or at least one condition needs to be true and with not not we'll do the opposite and well that is an introduction to logical operators in JavaScript