A lightweight, browser-based box score tracker for a basketball game.
Track points and fouls for players on Home and Away teams using quick buttons.
When you’re done, click Print Box Score to display stats on the page.
- Track Home and Away team stats separately
- Add +1 / +2 / +3 points to a player (prompts for player number)
- Add Foul to a player (prompts for player number)
- Automatically creates a player the first time you enter their number
- Prints a simple box score to the webpage
- Player stats are stored in two JavaScript objects:
playerStatsHomeplayerStatsAway
- Each player is stored by their player number as the key:
- Example:
playerStatsHome["12"] = { points: 8, fouls: 2 }
- Example:
- When you click a scoring/foul button:
- A prompt asks for the player number
- If the player already exists, it updates their points/fouls
- If not, it creates them with
setupPlayerHome()orsetupPlayerAway()
- Copy the code into a file named something like:
index.html
- Open the file in your browser:
- Double click it, or
- Right click → “Open With” → Chrome
That’s it.
If you want a local dev server:
VS Code Live Server
- Install the Live Server extension in VS Code
- Right-click
index.html - Click Open with Live Server
- Click +1 / +2 / +3 and enter the player number when prompted.
- Click Foul to add a foul to a Home player.
- Same idea using the Away buttons.
- Click Print Box Score to display current stats under the buttons.
When you click Print Box Score, the app prints something like:
- Home Team Stats
- Number 12 | Points: 8 | Fouls: 2
- Away Team Stats
- Number 5 | Points: 6 | Fouls: 1
(The display uses <br> line breaks for formatting.)
This project is a single HTML file:
index.html- Buttons + UI
<script>section with all JavaScript logic
- Player numbers are collected using
prompt() - There is no input validation (typing a blank value may create weird keys)
- Stats are stored in memory only (refreshing the page resets everything)
- Stats order may not be sorted numerically when printed (object key order)