I started an intro to JavaScript course, and we're going over logical operators. The goal of my script is to print a statement if a few conditions are met.
I have 3 variables (x, y, z for example) and I need it to print to console if x = a || b AND y = c || d AND z = e || f.
My code is:
var flavor = "strawberry";
var vessel = "cone";
var toppings = "cookies";
if (flavor === "vanilla" || "chocolate" && vessel === "cone" || "bowl" && toppings === "sprinkles" || "peanuts") {
console.log("I'd like two scoops of " + flavor + "ice cream in a " + vessel + "with " + toppings + ".");
} else {
console.log("No ice cream for you.");
}
It needs to have vanilla or chocolate && cone or bowl && sprinkles or peanuts to be true to print. With my code, it prints whatever values are in the variables, no matter what they are.
Is there some syntax wrong with my code? Or can you not compare that many things in one statement? As I said, it's an intro course, so I can't imagine it would be all that complex to start. Something just isn't firing in my brain. lol
Any help/explanations would be greatly appreciated.
Thanks in advance!!