B4Coder

🏏 Cricket Scoreboard · Mission 2 of 8

➕ The Total

The big number on the scoreboard is the team's total. The scorer also made a mistake: Fix sets a batter's runs to the right number. Whatever happens, the total must come out right.

Your mission

  1. Fix: if ball.kind == "fix", set the striker's runs to ball.runs (no ball faced). Otherwise, score as before.
  2. Then add up the total: total = 0, and For Each b in batters, total = total + b.runs.
  3. Fix a batter's runs on the right: the total follows.

Getting the mission ready…