Quotes help make search much faster. Example: "Practice Makes Perfect"

Monday, December 3, 2012

Codecademy: Codeyear Setting values using a ternary operator


//sample solution

var food = prompt("What food would you suggest?");
/*if (food === "taco") {
  foodType = "Mexican";
} else {
  foodType = "other";
}*/

//Re-write the above code using a ternary operator
foodType = food === "taco" ? "Mexican" : "other";

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts