Hi this is my js code.
var a = \' and have \' + $(\'#module_product_review_star_1 .pdp-link\')[1] ? $(\'#module_product_review_star_1 .p
+
has higher operator precedence (13) than the conditional operator (4), so your code is checking whether ' and have ' + $('#module_product_review_star_1 .pdp-link')[1]
is truthy, which it always will be. Surround everything past the in parentheses instead:
var a = ' and have ' + (
$('#module_product_review_star_1 .pdp-link')[1]
? $('#module_product_review_star_1 .pdp-link')[1].outerHTML
: 'not have'
);
That said, it would be better to write DRY code and put $('#module_product_review_star_1 .pdp-link')[1]
into a variable first:
var possibleLink = $('#module_product_review_star_1 .pdp-link')[1];
var a = ' and have ' + (
possibleLink
? possibleLink.outerHTML
: 'not have'
);