Last active
December 22, 2015 22:42
-
-
Save johntran/fb2efabe566b757a3022 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myCoffee = "HOT" | |
if (myCoffee === "HOT") { | |
/** always use "===" over "==". "===" is more strict than "==", so less errors. | |
* see http://stackoverflow.com/questions/523643/difference-between-and-in-javascript | |
*/ | |
console.log("Please proceed with caution"); | |
} else if (myCoffee === "IS NOT HOT") { | |
console.log("IT IS NOT HOT"); | |
} | |
// How John would write this for Maker Square: | |
function isMyCoffeeHot(myCoffee) | |
if (myCoffee === "HOT") { | |
return console.log("Please proceed with caution"); | |
} else { | |
return console.log("IT IS NOT HOT"); | |
} | |
/** If there are only two conditions, the second "if statement" is extraneous. | |
* If you want the two if's, there has to be a third option for coffee that is neither hot or cold. | |
*/ | |
var coffee = "HOT"; | |
isMyCoffeeHot(coffee); // returns "Please proceed with caution" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment