Challenge 2 — Solution Task: Using the ternary operator, write a single line that assigns "Pass" or "Fail" to a variable based on whether a score variable is 50 or above. Then write the equivalent using a full if/else block, and compare the two. = 50) ? "Pass" : "Fail"; echo $resultTernary . "
"; // Equivalent if/else version if ($score >= 50) { $resultIfElse = "Pass"; } else { $resultIfElse = "Fail"; } echo $resultIfElse; ?> Output: Pass Pass Notes: - Both versions produce the identical result - the ternary is simply a more compact way of writing the same "one condition, one of two outcomes" logic in a single expression rather than four lines. - The ternary reads naturally as "condition ? value-if-true : value-if-false". - For a simple assignment like this, many developers prefer the ternary specifically because it's shorter and keeps the whole decision on one line - but a full if/else remains clearer once the logic needs more than a single condition or more than two outcomes.