Skip to content

Instantly share code, notes, and snippets.

@johntran
Last active December 22, 2015 22:42
Show Gist options
  • Save johntran/fb2efabe566b757a3022 to your computer and use it in GitHub Desktop.
Save johntran/fb2efabe566b757a3022 to your computer and use it in GitHub Desktop.
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