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
Answer to your real question in the comments:
all2.forEach(function (e) { e.getAttribute("class") && only.push(e.getAttribute("class")); });