Premier League Predictor: Astro — Chapter 6, Exercise 1 ==================================================== TASK Explain, with a concrete example, why scorePrediction() checks for an exact score match before checking for a correct-result match, and what would go wrong if the outcome check ran first and returned immediately on a match. SOLUTION Every exact score match is automatically an outcome match too: if a prediction of 2-1 exactly matches an actual result of 2-1, then the outcome derived from that prediction (home win) also automatically matches the outcome derived from the actual result (also home win). There's no such thing as an exact score match that isn't also an outcome match — the reverse is what can differ (3-0 predicted against a 1-0 actual result matches on outcome only, not on score). Because of that relationship, if outcome() were checked first and the function returned immediately on a match, the exact-score branch would never be reached for a genuinely exact prediction. Concretely: a user predicts 2-1, and the match finishes 2-1. Under an outcome-first version of scorePrediction, the very first check would compute outcome(2, 1) === outcome(2, 1), find that HOME_WIN === HOME_WIN, and return POINTS_CORRECT_RESULT (10) right there — the function would never get as far as comparing the actual scorelines, so the 40-point exact match would silently be scored as a 10-point outcome match instead. Every single prediction that got the exact score right would be under-scored by 30 points, every time, with no error or warning of any kind. This is why the real order in the chapter's own implementation checks the exact score first and returns immediately on that branch: it's the only way to distinguish "this earned the full 40 points" from "this only earned the smaller 10-point consolation" before the more general outcome check ever gets a chance to fire. WHY THIS WORKS AS AN ANSWER ---------------------------- It states the precise logical relationship between an exact match and an outcome match (the former always implies the latter, never the reverse), works through a concrete scoreline pair to show the actual under-scoring bug that a reordered check would produce, and quantifies the real consequence (every exact prediction losing 30 points) rather than only asserting that the order "matters."