Use Ternary Operators - Daily JavaScript Tips #2
TL;DR The ternary operator is a shortcut for if/else
It contains three operands
A condition
A question mark ?
A colon :
if/else
let fruit;
if(fruit === "Apple"){
return "It is a fruit";
}else{
return "It is not a fruit";
}
Ternary operator...
h.dhairyashah.dev1 min read