xxxxxxxxxx
const answer = x > 10 ? "greater than 10" : "less than 10";
// or
if (something)
return;
// other code here
xxxxxxxxxx
javascript ( if / else ) shorthand
example : var hasName = (name === 'true') ? 'Y' :'N';
example2 : const answer = x > 10 ? "greater than 10" : "less than 10";
xxxxxxxxxx
condition ? doThisIfTrue : doThisIfFalse
1 > 2 ? console.log(true) : console.log(false)
// returns false
xxxxxxxxxx
// Shorthand If-Else Statement
condition ? expression1 : expression2;
// Example usage
const num = 10;
const result = num > 0 ? "positive" : "negative";
console.log(result); // Output: "positive"
xxxxxxxxxx
let showme || "if the variable showme has nothing inside show this string";
let string = condition ? 'true' : 'false'; // if condition is more than one enclose in brackets
let condition && 'show this string if condition is true';