Video Title: Learn JavaScript LOGICAL OPERATORS in 5 minutes ❗
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
Video Keywords: JavaScript
-
Sale!
Wireless WIFI Repeater Extender Amplifier Booster 300Mbps
$29.99$14.99 Add to cartWireless WIFI Repeater Extender Amplifier Booster 300Mbps
Categories: Electronics, Wi-Fi Router, Wireless Wi-Fi Extender Tags: 300Mbps, 802.11N, Amplifier, Booster, Extender, mobile wi-fi booster, Remote, WIFI, Wireless, Wireless WIFI, Wireless WIFI Repeater, Wireless WIFI Repeater Extender, Wireless WIFI Repeater Extender Amplifier, Wireless WIFI Repeater Extender Amplifier Booster, Wireless WIFI Repeater Extender Amplifier Booster 300Mbps$29.99$14.99 -
Sale!
Full RGB Light Design Gaming Headset Headphones with Mic
$24.99$14.99 Add to cartFull RGB Light Design Gaming Headset Headphones with Mic
Categories: Electronics, Gaming, Gaming Headsets Tags: Design, Full, Full RGB Light Design Gaming Headset, Full RGB Light Design Gaming Headset Headphones, Full RGB Light Design Gaming Headset Headphones with Mic, Gamer, Gaming, Gaming Headset Headphones, gaming headset wireless, Headphone, Headphones, Headset, Light, Mic, Package, RGB$24.99$14.99 -
Sale!
Wireless BlueTooth Multi-Device Keyboard Mouse Combo
$39.99$19.99 Add to cartWireless BlueTooth Multi-Device Keyboard Mouse Combo
Categories: Electronics, Gaming, Gaming Keyboards, Keyboard Mouse Combos Tags: Combo, Keyboard, keyboard mouse combos, Mouse, MultiDevice, Set, WireKeyboard Mouse Combo, Wireless, Wireless BlueTooth Keyboard Mouse Combo, Wireless BlueTooth Keyboard Mouse Combos, Wireless BlueTooth Multi-Device Keyboard Mouse Combo, Wireless BlueTooth Multi-Device Keyboard Mouse Combos$39.99$19.99 -
Sale!
High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar
$199.99$139.99 Add to cartHigh Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar
Categories: Gaming, Gaming Chairs Tags: Adjustable, Chair, computer chairs, Desk, Executive, Gaming, Girl, Headrest, High, High Back Leather Executive Adjustable Swivel Gaming Chair, High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest, High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar, High Back Leather Executive Adjustable Swivel Gaming Chairs, Leather, Lumbar, Office, Racing, Swivel$199.99$139.99 -
Sale!
Professional LED Light Wired Gaming Headphones with Noise Cancelling Microphone
$29.99$19.99 Select optionsProfessional LED Light Wired Gaming Headphones with Noise Cancelling Microphone
SKU: N/A Categories: Electronics, Gaming, Gaming Headsets Tags: Cancelling, Gaming, Gaming Headphones with Noise Cancelling Microphone, gaming headset, Headphones, Headset, LED, Light, Mic, Microphone, Noise, Professional, Professional LED Light Wired Gaming Headphones, Professional LED Light Wired Gaming Headphones with Noise Cancelling Microphone, Wired, Wired Gaming Headphones, Wired Gaming Headphones with Noise Cancelling Microphone$29.99$19.99 -
Sale!
Gaming Desk with LED Lights USB Power Outlets and Charging Ports
$349.99$249.99 Select optionsGaming Desk with LED Lights USB Power Outlets and Charging Ports
SKU: N/A Categories: Computer Desk, Gaming, Gaming Desk Tags: and Charging Ports, Charging, Desk, Desks, Gaming, gaming desk with led lights, Gaming Desks with LED Lights, Home, LED, Lights, Monitor, Office, Outlets, Port, Power, Room, Stand, USB, USB Power Outlets, White, Workstation$349.99$249.99 -
Sale!
Wired Mixed Backlit Anti-Ghosting Gaming Keyboard
$99.99$79.99 Add to cartWired Mixed Backlit Anti-Ghosting Gaming Keyboard
Categories: Electronics, Gaming, Gaming Keyboards Tags: Antighosting, Backlit, Blue, brown, Gaming, Gaming Keyboard, gaming keyboards, gaming keyboards and mouse, Keyboard, Laptop, Switch, Wired, Wired Mixed Backlit Anti-Ghosting Gaming Keyboard, Wired Mixed Backlit Anti-Ghosting Gaming Keyboards, Wired Mixed Backlit Gaming Keyboard$99.99$79.99 -
Sale!
Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset
$119.99$59.99 Add to cartWireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset
Categories: Electronics, Gaming, Gaming Headsets Tags: 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset, ANC, Audio, Bluetooth, Cancellation, Ear, Earphone, gaming headset, Headphones, Headset, Hi-Res Over the Ear Headphones Headset, HiRes, Noise, Wireless, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Headphones, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headsets$119.99$59.99 -
Sale!
Wired Sports Gaming Headset Earbuds with Microphone
$19.99$9.99 Select optionsWired Sports Gaming Headset Earbuds with Microphone
SKU: N/A Categories: Gaming, Gaming Headsets Tags: Accessories, Earbud, Earphone, Earphones, Gaming, gaming headset with microphone, Headphones, Headset, IOS, Microphone, Sports, Wired, Wired Sports Gaming Headset Earbuds, Wired Sports Gaming Headset Earbuds with Microphone, Wired Sports Headset Earbuds$19.99$9.99 -
Sale!
150W Universal Multi USB Fast Charger 16 Port MAX Charging Station
$49.99$29.99 Add to cart150W Universal Multi USB Fast Charger 16 Port MAX Charging Station
Categories: Charging Stations, Electronics Tags: 150W, 150W Charging Station, 150W Universal Multi USB Charging Station, 150W Universal Multi USB Fast Charger 16 Port MAX Charging Station, 150W Universal Multi USB Fast Charger 16 Port MAX Charging Stations, 150W Universal Multi USB MAX Charging Station, 16 Port MAX Charging Station, 3.5A, Charger, Charging, Fast, laptop charging stations, Max, Multi, Port, Stand, Station, Universal, USB$49.99$29.99
// logical operators = used to combine or manipulate boolean values
// (true or false)
// AND = &&
// OR = ||
// NOT = !
// ———- EXAMPLE 1 ———-
const temp = -100;
if(temp > 0 && temp <= 30){
console.log("The weather is GOOD");
}
else{
console.log("The weather is BAD");
}
// ———- EXAMPLE 2 ———-
const temp = -250;
if(temp <= 0 || temp > 30){
console.log("The weather is BAD");
}
else{
console.log("The weather is GOOD");
}
// ———- EXAMPLE 3 ———-
const isSunny = true;
if(!isSunny){
console.log("It is CLOUDY");
}
else{
console.log("It is SUNNY");
}
short and concise, good job!
Why do JavaScript developers prefer to work in the dark? Because they don't like "light" mode.
And i made the fith comment and noone can change that :O
hi sir bro
Btw where is Mr Pvssy
Day 2 ends Here!
First