-
-
Save desinas/de35f68bf12ec2e5b935856609d227e1 to your computer and use it in GitHub Desktop.
| /* | |
| * 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 + "."); | |
| } |
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!
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 ");
}
}
What Went Well
What Went Wrong: Your code should not pass when "walnuts" is used as the topping.
Feedback: Not everything is correct yet, but you're close!