question mark javascript code example
Example 1: javascript question mark
let result = condition ? value1 : value2
let result = 1 == 2 ? "YES" : "NO!"
console.log(result)
Example 2: question mark and colon in javascript
const isBlack = false;const text = isBlack ? 'Yes, black!' : 'No, something else.';console.log(text);
Example 3: ternary operator in javascript
FullName: (obj.FirstName && obj.LastName) ? obj.FirstName + " " + obj.LastName : "missing values",
Example 4: question mark operator javascript
voteable = (age < 18) ? "Too young":"Old enough"
Example 5: java question mark operator
return (a == b) ? a : b;
int n = (a < b) ? a + 10: b;