Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

ternary operator in typescript

const age = 18;
//condition ? whenTrue : whenFalse
const drink = (age >= 21) ? "beer" : "juice";
console.log(drink) //juice
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #ternary #operator #typescript
ADD COMMENT
Topic
Name
8+4 =