← Level 2 – Wizard

Lesson 8 of 8 ⏱ 60 minutes

Big challenge: bring your whole website to life

The final mission of Level 2. All the spells at once, plus a few new ideas on top.

Your mission

This time there’s no new material. You’ll get a list of tasks, and you already know everything you need for them. This is exactly what a real developer’s work looks like: you get a set of requirements and assemble them from things you already know.

Required part 🎯

Go through your website and make sure all five spells from this level are alive on it:

  1. The script connected on every page and no errors in the console (F12: nothing red should show up).
  2. Dark mode: a switch in the header on every page, and the choice is remembered.
  3. An interactive button or counter, at least one spell with a variable and a condition.
  4. A photo gallery with a lightbox: clicking makes a photo bigger.
  5. A quiz or a form with validation, at least one of these. Feel free to do both!

Optional extensions 🌟

Pick at least one (or come up with your own):

Greeting based on time of day

The website greets differently in the morning and in the evening:

<p id="day-greeting"></p>
const dayGreeting = document.getElementById("day-greeting");
const hour = new Date().getHours();

if (hour < 9) {
  dayGreeting.textContent = "Good morning! ☀️";
} else if (hour < 18) {
  dayGreeting.textContent = "Hi there, have a nice day!";
} else {
  dayGreeting.textContent = "Good evening! 🌙";
}

new Date() returns the current date and time, .getHours() pulls the hour out of it.

Random message on click

A different joke, trip idea, or team chant every time:

const messages = [
  "Practice makes perfect!",
  "Let's go, Eagles! 🦅",
  "You miss every shot you don't take.",
  "Fans are the twelfth player.",
];

const messageButton = document.getElementById("message-button");
const messageEl = document.getElementById("message");

messageButton.addEventListener("click", () => {
  const random = Math.floor(Math.random() * messages.length);
  messageEl.textContent = messages[random];
});

Math.random() returns a random number between 0 and 1, and the rest of the line turns it into a random position in the array.

Visit counter (just for you)

How many times have you opened your website? Save it in localStorage:

let visits = Number(localStorage.getItem("visits") ?? 0);
visits++;
localStorage.setItem("visits", visits);
console.log("You've opened this page " + visits + " times now");

Number(...) converts text from memory into a number, and ?? 0 means “if there’s nothing there, start from zero.”

Collapsible section (accordion)

Hide a long menu or roster under a clickable heading:

const sectionHeading = document.getElementById("expand-heading");
const sectionContent = document.getElementById("expand-content");

sectionHeading.addEventListener("click", () => {
  sectionContent.classList.toggle("hidden");
});

You already have the .hidden { display: none !important; } class from the gallery lesson.

Upload the new version to the internet

Your website on GitHub Pages is still the old version from Level 1! Upload the new one:

  1. Open your repository on github.com,
  2. Add file → Upload files,
  3. drag in the changed files (mainly script.js, style.css, and all the .html files) and click Commit changes.

In a minute, your spells will be running for everyone to see.

✅

Congratulations, Wizard! 🪄 Your website isn’t just pretty anymore: it’s alive. It reacts to clicks, remembers choices, asks questions and answers them. And you know how every single line works. In Level 3 – Master, you’ll learn to build websites like the pros: React, components, and your own server.

What to take away from this level

🏆 Your diploma

Finale of Wizard

Once you check off every lesson, you can print a certificate.