var canDrive = age > 16 ? 'yes' : 'no';
? : is called a ternary operator and acts just like an
else when used in an expression
Ternary operator (Conditional operator)
var age = 19;
var canDrive = age > 16 ? 'YES' : 'No';
Do comment if you have any doubts and question on this tutorial.
Note: The All JS Examples codes are tested on the Safari browser (Version 12.0.2) and Chrome.
OS: macOS 10.14 Mojave
Code: HTML 5 Version