I'm trying to understand how logical operators can be combined in Javascript. For instance, how will i print out a statement if the following conditions are true
- if flavor is set to vanilla or chocolate and
- if vessel is set to cone or bowl and
- if toppings is set to sprinkles or peanuts
This is the code i have written but comparison is false, it still prints out a message
var flavor = 'vanilla';
var vessel = 'cup';
var toppings = 'peanuts';
if (flavor === 'vanilla' || 'chocolate' && vessel === 'cone' || 'bowl') {
if (toppings === 'peanuts' || 'sprinkles') {
console.log('I\'d like two scoops of ' + flavor + ' ice cream in a ' + vessel + ' with ' + toppings + '.');
}
}
Result - I'd like two scoops of vanilla ice cream in a plate with peanuts.
What am I missing? Can't seem to see where the error is coming from.