Keep Score for Two Players

Write the code, see it run, pass the checks.

The problem

  • medium
  • Code

Keep score in a game between Ada and Ben. Write a Player component that shows one player's score as a line like "Ada: 0" and a button named "Point to Ada", and use it twice. Keep both scores in App, so it can show who's ahead in one line: "Tied", or for example "Ada leads by 2" or "Ben leads by 1". A "New game" button puts both scores back to 0.

Your code must pass

  • Both start at 0, tied
  • Each button scores for its own player
  • The leader line follows the scores
  • New game resets both scores