question mark condition in javascript code example
Example 1: question mark and colon in javascript
const isBlack = false;const text = isBlack ? 'Yes, black!' : 'No, something else.';console.log(text);// "No, something else."
Example 2: question mark operator javascript
voteable = (age < 18) ? "Too young":"Old enough"
// condition ? if true : if false