define ternary code example
Example 1: ternary operator
(condition) ? (if true, do this) : (otherwise, do this)
Example 2: ternary
isMember ? '$2.00' : '$10.00'
// isMember true => output: "$2.00"
// isMember false => output: "$10.00"
// isMember null => output: "$10.00"
Example 3: ternary
let greeting = ( isBirthday ) ? 'Happy birthday Mrs. Smith — we hope you have a great day!' : 'Good morning Mrs. Smith.';