use ternary operator in JavaScript output