Connect a script and use the Console

Understand script loading and inspect real values in the Console.

Difficulty
beginner
Time
30 minutes
Last verified
9/21/2026

What you will build

Understand script loading and inspect real values in the Console.

Understand the idea first

Understand script loading and inspect real values in the Console.

Build it step by step

<script src="js/app.js" defer></script>;

// js/app.js
console.log('Study tracker loaded');
console.table({ lessons: 12, completed: 3 });
  1. Open the project from the previous lesson and record its current result.
  2. Type and run the example, then complete this task: Connect the script on three pages, log progress only on Home, and locate its source line in Console.
  3. Change at least one input, predict the result, and verify it.
  4. Create and repair this lesson's typical failure: If app.js returns 404, recalculate the relative path from the current HTML file.

Read the important lines

  • Understand script loading and inspect real values in the Console.
  • Read the code as input, processing, and output; point to each part.
  • A first successful run is not enough; verify a different input and an edge case.

Common mistakes and what to check

SymptomWhat to check
The result differs from the predictionIf app.js returns 404, recalculate the relative path from the current HTML file.
Nothing changes after refreshSave the file, verify the script path, and read the first relevant Console error.

Practice without copying

Connect the script on three pages, log progress only on Home, and locate its source line in Console.

Check the answer after you try

Rebuild it without copying and explain each decision. Key check: If app.js returns 404, recalculate the relative path from the current HTML file.

Completion check

  • I produced the required visible result
  • I can explain the input, processing, and output
  • I tested normal, edge, and failure cases

Your privacy choices

Necessary storage is always on. Optional analytics and support services load only after consent.