Skip to content

Instantly share code, notes, and snippets.

@desinas
Last active March 15, 2023 12:04
Show Gist options
  • Save desinas/de35f68bf12ec2e5b935856609d227e1 to your computer and use it in GitHub Desktop.
Save desinas/de35f68bf12ec2e5b935856609d227e1 to your computer and use it in GitHub Desktop.
Ice Cream quiz (3-6) from Udacity Front End Developer
/*
* Programming Quiz: Ice Cream (3-6)
*
* Write a single if statement that logs out the message:
*
* "I'd like two scoops of __________ ice cream in a __________ with __________."
*
* ...only if:
* - flavor is "vanilla" or "chocolate"
* - vessel is "cone" or "bowl"
* - toppings is "sprinkles" or "peanuts"
*
* We're only testing the if statement and your boolean operators.
* It's okay if the output string doesn't match exactly.
*/
// change the values of `flavor`, `vessel`, and `toppings` to test your code
var flavor = "strawberry";
var vessel = "cone";
var toppings = "cookies";
// Add your code here
if ((flavor === "vanilla" || flavor === "chocolate")
&& (vessel === "cone" || vessel === "bowl")
&& (toppings === "sprinkles" || toppings === "peanuts")) {
console.log("I'd like two scoops of " + flavor + " ice cream in a " + vessel + " with " + toppings + ".");
}
@desinas
Copy link
Author

desinas commented Dec 15, 2017

What Went Well
...

  • Your code should not log anything when the flavor is something other than "vanilla" or "chocolate"
  • Your code should not log anything when the vessel is something other than "cone" or "bowl"
  • Your code should not log anything when toppings is something other than "sprinkles" or "peanuts"

Feedback: Your answer passed all our tests! Awesome job!

@zuhaasaqlain
Copy link

mine working perfectly in javascript console but not in Udemy
var flavor = "chocolate";
var vessel = "cone";
var toppings = "sprinkles";

// Add your code here
if(flavor === "vanilla" || flavor === "chocolate") {
if(flavor === "vanilla" && vessel === "cone" || vessel === "bowl" && toppings === "spirnkles" || toppings === "peanuts"){
console.log( "I'd like two scoops of "+ flavor + " ice cream in a "+ vessel + " with " + toppings +".")
} else if (flavor === "chocolate" && vessel === "cone" || vessel === "bowl" && toppings === "spirnkles" || toppings === "peanuts"){
console.log( "I'd like two scoops of "+ flavor + " ice cream in a "+ vessel + " with " + toppings +".")
} else {
console.log("pick vanilla or chocolate ");
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment