Answers for "ternary operator js else if"

2

javascript ternary operator

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';
Posted by: Guest on October-12-2021
0

javascript ternary operator

// condition ? expr1 : expr2

// example:

let bar = 2
let foo = 0
let result;

result = bar > foo ? 1 : -1; // result = 2 > 0 ? 1 (true) : -1 (false);

// output: result = 1
Posted by: Guest on December-21-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language