Practice and reinforce the concepts from Lesson 11
Master professional debugging with Browser DevTools, strategic console logging, AI-assisted workflows, and systematic problem-solving by fixing 11 intentional bugs in a Spelling Bee game.
Required: Concept 13 complete, Chrome/Firefox, Trae IDE, 60 min
Download: Activity-11-Debugging-Template.zip
Setup: Extract -> Open in Trae IDE -> Run Live Server -> Open DevTools (F12)
Template Contains:
index.html - Game interface with stylingwords.js - Word bank with 2 intentional bugsgame.js - Game logic with 9 intentional bugsstyle.css - Complete styling (no bugs)Quick Test: Open index.html -> DevTools (F12) -> Try playing -> Observe errors
| Exercise | Tab | Objective | Key Steps | Success Criteria |
|---|---|---|---|---|
| 1 | Console | Error detection | Refresh -> Note red errors -> Click filename | Screenshot showing errors |
| 2 | Elements | DOM inspection | Use selector -> Inspect #current-word, input, button -> Check Styles |
Answer element state questions |
| 3 | Application | localStorage | Local Storage -> Find spellingBeeGame -> View/edit JSON |
Screenshot of data |
| 4 | Network | Resource loading | Refresh -> Check 4 requests (HTML, CSS, 2 JS) -> Verify 200 OK | No 404 errors |
| Bug # | Symptom | Location | Fix | Verify |
|---|---|---|---|---|
| 1 | TypeError: Cannot read property 'word' of undefined |
words.js line 9 |
Return entire object, not .word string |
Error disappears |
| 2 | Duplicate words appear | words.js line 15 |
Remove ! operator |
No repeats |
| 3 | No word displays on load | game.js bottom |
Add DOMContentLoaded listener with loadGameState() + displayWord() |
Word appears |
| 4 | Cannot read property 'definition' |
game.js displayWord() |
Fixed by Bug 1, verify with console.log(wordObj) |
Console shows object |
| 5 | Only accepts uppercase | game.js line 61 |
Add .toUpperCase() to both sides |
Lowercase accepted |
| 6 | Streak doesn't reset | game.js line 68 |
Change = gameState.streak to = 0 |
Resets to 0 |
| 7 | Bonus shows too early | game.js updateScore() |
Move feedback inside conditional, use >= |
Shows after 3+ |
| 8 | Negative score from hints | game.js showHint() |
Add if (score < 5) check |
Blocks hint |
| 9 | localStorage bloated | game.js save/load functions |
Only save score, streak, usedWords |
Fresh word, saved score |
Bad Prompt: "My game doesn't work. [200+ lines] Fix it." -> ~2000 tokens ($0.02)
Good Prompt: "Case-sensitive comparison issue. Code: if (userInput === gameState.currentWord) {...} Fix?" -> ~150 tokens ($0.0005)
Task: Write effective prompt for Bug 5 -> Calculate Haiku vs Sonnet cost -> Decide when to use each model
Rewrite with error message + code + expected behavior:
Task: Rename getRandomWord() in words.js -> DON'T update call in game.js -> Trace error
Steps: Console error -> Click to trace -> Find renamed function -> Fix call
Deliverable: Screenshots documenting debugging process
Submit PDF/Google Doc with:
Part One: DevTools Screenshots
#current-word), Application (localStorage), Network (file requests)Part 2: Bug Fixes
Part 3: AI Debugging
Reflection (5 sentences):
Ctrl+Shift+M) -> Test responsiveShortcuts: F12 (DevTools) | Ctrl+Shift+J (Console) | Ctrl+Shift+C (Inspect) | Ctrl+Shift+R (Hard refresh)
Console: log() (basic) | error() (red) | table() (data) | group() (organize)
AI: Haiku (syntax/simple) | Sonnet (complex/multi-file) | Always include: error + code + expected behavior