I\'m trying to convert the following if-else to it\'s ternary operator representation in javascript as follows
var x = 2; if (x === 2) {alert(\"2\");} else
In that case you don't need to use Ternary operator. Ternary operator requires a third argument.
condition ? expr1 : expr2
Lokki at Conditional (ternary) Operator
You can use the if statement
if ( t == 2 ) alert(1);