Ternary Operator


Inline if this then that else this other thing. Handy when you need to do this in a template literal.

// condition ? yep : nope;

let my_variable = condition ? "yep" : "nope";

// Example

let dads_birthday = false;

let str = `Your Dads Birthday: ${ dads_birth_day ? dads_birth_day : "I forgot." }` // ES6

// str would be "I forgot."