Ternary operator '?': Multiple '?'

Let age = prompt('age?', 18);

let message = (age < 3) ? 'Hi, baby!' :
  (age < 18) ? 'Hello!' :
  (age < 100) ? 'Greetings!' :
  'What an unusual age!';

alert( message );

A sequence of question mark ? operators allows returning a value that depends on more than one condition.

Related concepts

Ternary operator '?': Multiple '?' — Structure map

Clickable & Draggable!

Ternary operator '?': Multiple '?' — Related pages: