Project: An Arcade Score Toolkit

At the arcade’s front desk, you wrote helpers that count tokens and pick prizes. Now the shooting gallery game needs a short line on its screen after each round that tells the player how they did. That’s your project for this course, an arcade score toolkit built from three small functions.

In this lesson, you’ll read the brief, plan the functions, and work out the right answers by hand. In the next exercise, you’ll build the toolkit on-site. Keep a pen and paper or an empty note nearby for some arithmetic.

Read the Brief

The shooting gallery has three rules.

  • Score: Each target a player hits is worth 10 points, and each miss costs 5 points. A score can’t go below 0, so a round that would come out negative scores 0.
  • Rank: A score below 100 earns the rank "Rookie". From 100 to 249, inclusive, the rank is "Pro". A score of 250 or more is "Legend".
  • Message: The screen shows the player’s name, their score, and their rank, written exactly like Ada: 130 points (Pro).

Ada hit 14 targets and missed 2, so her score is 14 * 10 - 2 * 5, which is 140 - 10, or 130. That’s between 100 and 249, so she’s a Pro.

Look Closely at the Rules’ Edges

Mistakes in rules like these tend to hide at the edges, where one rank ends and the next begins. Everything from 0 to 99 is Rookie. Pro starts at exactly 100 and ends at 249. Legend starts at exactly 250. So 99 is still Rookie, but 100 is already Pro, and 249 is the highest Pro score.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.