Created
August 27, 2017 14:59
-
-
Save prof3ssorSt3v3/a3e1fb852840a6caba2bcd652693599c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Binary Logical Operators | |
// AND && | |
// OR || | |
// creating compound if statements | |
let ingredients = ['ham', 'onion', 'tomato']; | |
let sandwichHas = function(ingredient){ | |
for(let i of ingredients){ | |
if( i == ingredient){ | |
return true; | |
} | |
} | |
return false; | |
//if this line omitted it returns undefined | |
//which is also a falsey value | |
} | |
if( sandwichHas('ham') || sandwichHas('chicken') || sandwichHas('beef')){ | |
console.log('Sandwich has meat') | |
}else{ | |
console.log('No meat') | |
} | |
if( sandwichHas('lettuce') && sandwichHas('onion') ){ | |
console.log('it has both') | |
}else{ | |
console.log('it has NOT both but maybe one of them') | |
} | |
if( (sandwichHas('cheddar') && sandwichHas('onion')) || | |
sandwichHas('onion') && sandwichHas('tomato')){ | |
console.log('cheese and lettuce ... OR onion') | |
}else{ | |
console.log('failed final test') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment