Fifi |
For and(&&), remember:
true && true // => true
true && false // => false
false && true // => false
false && false // => false
Whereas or(||):
true || true // => true
true || false // => true
false || true // => true
false || false // => false
Lastly, not(!):
!true // => false
!false // => true
Here is a code I wrote which uses &&, ||, !:
// set variables to either true or false:
var iLoveYoga = true;
var iLoveRunning = true;
if(iLoveYoga && iLoveRunning) {
// if iLoveYoga AND iLoveRunning:
console.log("Awesome, yoga and running work hand-in-hand!");
} else if (!(iLoveYoga || iLoveRunning)) {
// if NOT iLoveYoga OR iLoveRunning:
console.log("You've gotta get your lazy butt off the couch and out the door!!!");
} else {
console.log("You only like one, but not the other?");
}
No comments:
Post a Comment