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
Do this :
(t==2)?(alert("1")):null;
You could replace null by any expression that has no side effect. () is not a valid expression.