Professional Documents
Culture Documents
Ternary Operator
Ternary Operator
console.log("It costs $" + (adult ? "40.00" : "20.00") + " to attend the concert.
Pick up your tickets at the " + (preorder ? "will call" : "gate") + ".");
var a = false;
var b = true;
var check =
if a true
{ if b true
{then a & b }
else
{ just a }
}
else
if b true
{ then just b }
else
undef
( substituting.... if?true then ... for "?" , and ...else: ... for " : " )
var check = a if?true then (b if?true then "a & b true" else: "just a true") else:
(b if?true then"b true" else: undefined);
console.log(category);