⛰ Phase 1 — Foundations · Week 3

JavaScript Without the Pain

⏱ ~3 hours 📚 4 lessons 🛠 VS Code · Claude AI · GitHub · Browser Console

JavaScript is what makes websites do things. The WV tourism site that shows live trail conditions? JavaScript. The coal company dashboard updating in real time? JavaScript. This week you'll make your pages interactive.

Lesson 1 of 4

💡 What JavaScript Is For

HTML = structure. CSS = style. JavaScript = behavior. It's the code that runs when you click a button, submit a form, or see a notification pop up. If the page does something in response to what you do — that's JavaScript.

🧩 The three layers of every webpage
📄
HTML
Structure & content
+
🎨
CSS
Visual style
+
JavaScript
Behavior & interaction
=
🌐
Real App
Everything together
💡
The mental model

JavaScript can read and change anything on the page. It watches for events (clicks, typing, scrolling), runs code when they happen, and updates what you see. That's the entire model.

script.js
// Find a button and watch for clicks
document.getElementById('myButton').addEventListener('click', function() {
  // This runs when the button is clicked
  alert('You clicked it!');
});
Lesson 2 of 4

🖱 Click Events: Make Things Do Stuff

An "event" is anything the user does — click, type, hover, scroll. JavaScript can listen for any event and run code when it happens. The most common: click.

1

Give your HTML element an ID

IDs are like name tags. <button id="myBtn">Click me</button>. The ID is how JavaScript finds the element.

2

Use JavaScript to find it and add a listener

document.getElementById('myBtn') finds your button. .addEventListener('click', function() {...}) watches it for clicks.

3

Write what happens inside the function

Anything between the curly braces { } runs when the event fires. Change text, show/hide things, update a counter — anything.

index.html + script.js
<!-- HTML -->
<button id="scoreBtn">Add Point</button>
<p id="score">Score: 0</p>

/* JavaScript */
let count = 0;

document.getElementById('scoreBtn').addEventListener('click', function() {
  count = count + 1;
  document.getElementById('score').textContent = 'Score: ' + count;
});
🤖
Ask Claude to explain any JS line

Paste any JavaScript line into Claude and ask "Explain this to me like I'm a beginner." This is the fastest way to build your JavaScript vocabulary. Do it constantly.

Lesson 3 of 4

🔄 Show and Hide Content

One of the most common things JavaScript does: showing or hiding parts of a page based on what you click. This is the foundation of tabs, accordions, modals, and menus.

toggle.js
// Show/hide a section when button is clicked
document.getElementById('toggleBtn').addEventListener('click', function() {
  const section = document.getElementById('hiddenSection');

  if (section.style.display === 'none') {
    section.style.display = 'block';  // show it
  } else {
    section.style.display = 'none';   // hide it
  }
});
💡
Don't stress about syntax yet

The goal this week isn't to memorize JavaScript. It's to understand the pattern: find element → listen for event → run code that changes something. Claude handles the syntax. You handle the logic.

Lesson 4 of 4

🐛 Debugging with Claude

Code breaks. Always. The skill isn't avoiding errors — it's knowing how to find and fix them fast. Your two debugging tools: the browser Console and Claude.

1

Open the Console (in DevTools)

Right-click → Inspect → Console tab. This shows JavaScript errors in red. Every error message tells you which file, which line, and what went wrong.

2

Copy the error message exactly

Don't try to interpret it yourself yet. Copy the red error text.

3

Paste it to Claude with your code

Claude will tell you exactly what's wrong and show you the fix. Do this every time.

My JavaScript isn't working. Here's the error from the Console: [paste the red error message] Here's my full code: [paste HTML and JS] What's wrong and how do I fix it?

🏗 Week 3 Project

Interactive Quiz Page

Build This

A click-through quiz with score tracking

Put JavaScript into practice by building a simple trivia quiz. Use Claude to generate the logic, then customize the questions.

  • 3–5 questions on any topic you like
  • Multiple choice buttons for each answer
  • Right/wrong feedback shown after each click
  • A score counter that tracks how many you got right
  • A "restart" button at the end

Build me a JavaScript quiz page about [your topic]. 5 multiple choice questions, 4 options each. When I click an answer: highlight it green if correct, red if wrong. Show my running score at the top. At the end, show my total score and a Restart button. Keep the code clean and commented — I'm a beginner learning JS.

Week 3 Done!

Mark it complete and keep your momentum going.