Answers for "javascript && as ternary condition"

14

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
0

ternary operator js

condition ? expression1 : expression2 
// Will return expression1 if condition = true and expression2 if condition != true
Posted by: Guest on March-09-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language