if else in single line javascript code example
Example 1: js if else statement one line
var time = Date().getHours(); // or something
var clockTime = time > 12 ? 'PM' : 'AM' ;
Example 2: one line if else if statement javascript
var variable = (condition) ? (true block) : ((condition2) ? (true block2) : (else block2))