Trying to wrap my head around the concept of combining logical operators in Javascript. Specifically, I'm wondering how to output a statement only if certain conditions are met:
- If flavor is either vanilla or chocolate.
- If vessel is either cone or bowl.
- If toppings are either sprinkles or peanuts.
I've written this code, but even though the comparison seems false, it's still displaying a message:
var flavor = 'vanilla';
var vessel = 'cup';
var toppings = 'peanuts';
if ((flavor === 'vanilla' || flavor === 'chocolate') && (vessel === 'cone' || vessel === 'bowl')) {
if (toppings === 'peanuts' || toppings === 'sprinkles') {
console.log('I\'d like two scoops of ' + flavor + ' ice cream in a ' + vessel + ' with ' + toppings + '.');
}
}
The result currently shows:
I'd like two scoops of vanilla ice cream in a plate with peanuts.
What am I overlooking? Struggling to pinpoint where the mistake lies.