Answers for "ternary"

45

ternary operator

(condition) ? (if true, do this) : (otherwise, do this)
Posted by: Guest on May-14-2020
12

javascript if shorthand

condition ? doThisIfTrue : doThisIfFalse

1 > 2 ? console.log(true) : console.log(false)
// returns false
Posted by: Guest on May-21-2020
50

js ternary

condition ? ifTrue : ifFalse
Posted by: Guest on April-10-2020
15

javascript ternary operator

//ternary operator syntax and usage:
condition ? doThisIfTrue : doThisIfFalse

//Simple example:
let num1 = 1;
let num2 = 2;
num1 < num2 ? console.log("True") : console.log("False");
// => "True"

//Reverse it with greater than ( > ):
num1 > num2 ? console.log("True") : console.log("False");
// => "False"
Posted by: Guest on February-02-2020
1

ternary

let greeting = ( isBirthday ) ? 'Happy birthday Mrs. Smith — we hope you have a great day!' : 'Good morning Mrs. Smith.';
Posted by: Guest on April-18-2021
2

ternary

isMember ? '$2.00' : '$10.00'
// isMember true =>  output: "$2.00"

// isMember false =>  output: "$10.00"

// isMember null =>  output: "$10.00"
Posted by: Guest on September-23-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language