10 JavaScript DOM Games — Exercises & Tests

Each card contains the UI, controls, and a short explanation. Use the “Run All Tests” button at the bottom to validate core interactions automatically.

1) Click Counter Frenzy

Build a 10-second clicker challenge. Highest count wins.
eventsstatetimers
⏱️ 10s Score: 0

How it works: “Start” enables the click button and starts a countdown with setInterval. Each click increments local state and updates the DOM. When time hits 0, buttons disable.

Learning outcomes: click events, intervals, enabling/disabling controls, textContent updates.

2) Whack-A-Mole Lite

Tap the highlighted “mole” squares before they move.
classListgridgame loop
Score: 0

How it works: Every 700ms a random cell gets the mole class. Clicking that cell adds a point and clears it. Uses delegation-free per-cell listeners for clarity.

Learning outcomes: DOM creation, random selection, class toggling, cleanup timers.

3) Memory Match (4×2)

Flip 2 at a time. Match pairs to clear the board.
datasettimeoutsarray shuffle
Matches: 0/4

How it works: Shuffle pairs, render cards with hidden values in data-val. Track two active flips; if equal, mark matched, else flip back after a short delay.

Learning outcomes: state machines, attribute APIs, shuffling, conditional UI.

4) Reaction Time Tester

Wait for green, then click fast.
timeoutsevent timing
Result: ms
Wait…

How it works: “Start” arms a random delay. On green, timestamp; on click, compute delta with Date.now().

Learning outcomes: timing, guarding early clicks, visual feedback.

5) Typing Sprint (10s)

Type the prompt text as fast & accurately as you can.
input eventsdiffing
10sChars: 0

How it works: Start sets prompt & countdown. On each input, compare typed vs prompt; count correct characters. Bar fills by match percentage.

Learning outcomes: input handling, string comparison, simple progress meter.

6) RGB Color Guess

Pick the square that matches the shown RGB.
stylesrandom
Target: Score: 0

How it works: Generate 6 random colors; choose one as target. Click to match; correct increments score and regenerates.

Learning outcomes: inline styles, color generation, comparing computed choices.

7) Simon Says (Sequence Memory)

Repeat the flashing sequence of pads.
async flowpromisesqueues
Level: 0
A
B
C
D

How it works: Game appends a random pad to the sequence, flashes it (via temporary class), then collects user input to verify order.

Learning outcomes: sequencing, async delays, input gating.

8) Drag-and-Drop Sorter

Drag numbers into ascending order.
drag & dropDOM reorder
Correct: 0/5

How it works: HTML5 drag events move number chips into five slots; “Check” compares slot order to sorted target.

Learning outcomes: drag events, dataTransfer payloads, DOM insert positions.

9) Mini Maze (Arrow Keys)

Use arrow keys to reach the goal square.
keyboardcollision
Status: Ready

How it works: Grid encoded as a 1D array; player moves if next cell isn’t a wall. Checks for goal collision.

Learning outcomes: keyboard listeners, bounds checking, grid math.

10) Catch the Falling Stars

Move the basket to catch falling items.
animationcollisionrequestAnimationFrame
Score: 0

How it works: Simple game loop with requestAnimationFrame. Mouse moves the basket; stars fall; AABB collision counts catches.

Learning outcomes: canvas basics, animation timing, hit-testing.