Oh man, it is so totally freeing not having to create those stale blog posts! Here are two more
// here's my first version:
var omelette = prompt("Good morning! Are you hungry for breakfast? The chickens and ducks laid a whole bunch of eggs, so we're planning to make omelettes for everyone. Do you eat meat?").toUpperCase();
switch(omelette) {
case 'YES':
var salmon = prompt("Do you eat fish?").toUpperCase();
if(salmon === 'YES') {
console.log("One smoked salmon and tomato omelette coming right up!");
} else {
console.log("We'll have your ham and cheese omelette plated in a jiffy!");
}
break;
case 'NO':
var dairy = prompt("Do you eat dairy?").toUpperCase();
if(dairy === 'YES') {
console.log("Well here's a cheesy mushroom and onion omelette... one of my favorites!");
} else {
console.log("Sorry, we don't have any omelettes for you!");
}
break;
default:
console.log("Say you don't like omelettes? Well we have some soggy oatmeal leftover from yesterday's brunch...");
}
// here's the second (and slightly more intricate) one:
var hungry = prompt("So I see you're feeling a little hungry. Well, what time is it (BREAKFAST, LUNCH, or DINNER time)?").toUpperCase();
switch(hungry) {
case 'BREAKFAST':
var meat_breakfast = prompt("It's breakfast time! Do you eat meat?").toUpperCase();
var dairy_breakfast = prompt("Do you eat dairy?").toUpperCase();
if(meat_breakfast === 'YES' && dairy_breakfast === 'YES') {
console.log("Have some bacon and eggs!");
} else if(meat_breakfast === 'YES' && dairy_breakfast === 'NO') {
console.log("Allergic to dairy? How about some sausage and hashbrowns?");
} else if(meat_breakfast === 'NO' && dairy_breakfast === 'YES') {
console.log("What about a tomato and spinach omelette?");
} else {
console.log("How about some fresh fruit?");
}
break;
case 'LUNCH':
var meat_lunch = prompt("Lunchtime! Do you eat meat?").toUpperCase();
var dairy_lunch = prompt("What about dairy? Can you have milk? Eggs?").toUpperCase();
if(meat_lunch === 'YES' && dairy_lunch === 'YES') {
console.log("Alrighty, how about a ham and cheese sandwich? Does that sound good to you?");
} else if(meat_lunch === 'YES' && dairy_lunch === 'NO') {
console.log("Well what about just a tunafish sandwich?");
} else if(meat_lunch === 'NO' && dairy_lunch === 'YES') {
console.log("Grilled cheese for one! Coming right up!");
} else {
console.log("What about a classic PB and J sandwich? Does that sound good to you?");
}
break;
case 'DINNER':
var meat_dinner = prompt("Ah, the last and BEST meal of the day! Do you include meat in your diet?").toUpperCase();
var dairy_dinner = prompt("How about dairy?").toUpperCase();
if(meat_dinner === 'YES' && dairy_dinner === 'YES') {
console.log("What about some pepperoni pizza?");
} else if(meat_dinner === 'YES' && dairy_dinner === 'NO') {
console.log("How about the classic spaghetti and meatballs? We'll hold the cheese, don't worry about that!");
} else if(meat_dinner === 'NO' && dairy_dinner === 'YES') {
console.log("In the mood for mac and cheese! I know I am!");
} else {
console.log("Well in that case, what about a nice refreshing kale salad?");
}
break;
default:
console.log("Hmm... you sure you're hungry?");
}
P.S. I started using canv.as and it is so freaking fun. Here's my page.
No comments:
Post a Comment