Ternary Operator

The Conditional (Ternary) Operator

condition ? a : b is the expression form of if...else (Conditional Branching); only the chosen branch runs. Being right-associative, c1 ? x : c2 ? y : z reads as an else if ladder.

A ternary chain as a grading ladderJavaScriptLive
const grade = (n) => (n >= 90 ? "A" : n >= 75 ? "B" : n >= 50 ? "C" : "F");
console.log([95, 80, 51, 12].map(grade).join(" "));

For side effects or long ladders, use if or a lookup object instead.