Skip to content

Instantly share code, notes, and snippets.

@rickosborne
Created July 23, 2011 00:53
Show Gist options
  • Save rickosborne/1100786 to your computer and use it in GitHub Desktop.
Save rickosborne/1100786 to your computer and use it in GitHub Desktop.
var makeSandwich = function (bread, meat) {
var sandwich = "My sandwich is " + meat + " on " + bread + ".";
return sandwich;
};
console.log(makeSandwich("rye","roast beef"));
var toppingAvailable = function (topping) {
var available = {
"pepperoni": true,
"mushrooms": true
};
if (available[topping] === true) { return true; }
else { return false; }
};
console.log("I can get pepperoni: " + toppingAvailable("pepperoni"));
console.log("I can get pineapple: " + toppingAvailable("pineapple"));
var willFeed = function (slices) {
var slicesPerPerson = 3;
var people = Math.floor( slices / slicesPerPerson );
return people;
};
console.log("An 8-slice pizza will feed " + willFeed(8) + " people.");
console.log("A 16-slice pizza will feed " + willFeed(16) + " people.");
// JSON data
var pizzas = {
"white": {
"name": "Pizza Bianca",
"toppings": [ "ricotta", "garlic" ]
},
"meat": {
"name": "Meat Lover's",
"toppings": [ "pepperoni", "ham", "sausage", "bacon" ]
},
"veggie": {
"name": "Veggie Lover's",
"toppings": [ "onions", "mushrooms", "peppers", "olives" ]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment