1const num = 6;
2if (num <= 4 || num <= 8) {
3 console.log('true')
4} else {
5 console.log('false')
6}
7//Expected output:true
1//&& returns true if both values are true
2//or returns the second argument if the first is true
3var a = true
4var b = ""
5var c = 1
6
7true && "" //""
8"" && 1 //""
9false && 5 //false
1// There are 3 Javascript Logical Operators
2// || (OR)
3// && (AND)
4// ! (NOT)
5
6if (a || b) {
7 console.log("I will run if either a or b are true");
8}
9
10if (a && b) {
11 console.log("I will run, if and only if a and b are both true");
12}
13
14if (!a) {
15 console.log("I will only run if a is false");
16}
17
18if (a) {
19 console.log("I will only run if a is true");
20}
1const num = 6;
2if (num <= 7 && num <= 8) {
3 console.log('true')
4} else {
5 console.log('false')
6}
7//Expected output:true
1n1 = !true // !t returns false (the opposite of true)
2n2 = !false // !f returns true (the opposite of false)
3n3 = !'' // !f returns true (in JavaScript, an empty string is falsey, thus the opposite of a falsey value here is truthy.)
4n4 = !'Cat' // !t returns false (non empty string is truthy, thus opposite is falsy)