Lesson overview

Build browser interaction step by step

Follow the modules in order. Each task adds a piece to the final Interactive Readiness Quiz Card.

Topic 1

What is JavaScript?

JavaScript adds behaviour to web pages. HTML gives structure, CSS gives style and JavaScript makes the page respond.

HTML structure+CSS style+JavaScript behaviour

HTML, CSS and JavaScript roles

Think of a quiz card: HTML creates the card, CSS makes it look polished and JavaScript calculates the result.

<button id="checkBtn">Check readiness</button>

Real-life example: A button shows a score message only after a learner clicks it.

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
HTML, CSS and JavaScript rolesThe main idea in this part of the lessonIt gives you one building block for the final project<button id="checkBtn">Check readiness</button>
exampleA small sample that shows the ideaIt helps you see how the concept looks in practice<button id="checkBtn">Check readiness</button>
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

Name one action on a website that needs JavaScript.

Mini-project task

Write the purpose of your readiness quiz card in one sentence.

Real browser interactions

JavaScript can change text, add classes, read input values, open menus and save simple browser-side data.

console.log("Readiness quiz loaded");

Beginner mistake to avoid

Do not expect JavaScript alone to create accounts or secure databases. This page teaches browser-side interaction only.

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
Real browser interactionsThe main idea in this part of the lessonIt gives you one building block for the final projectconsole.log("Readiness quiz loaded");
exampleA small sample that shows the ideaIt helps you see how the concept looks in practiceconsole.log("Readiness quiz loaded");
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

List two things your quiz card should update on screen.

Mini-project task

Plan the text areas your quiz card will show: title, score and feedback.

Topic checkpoint

You can explain JavaScript as the behaviour layer that makes a static page interactive.

Topic 2

Variables and data types

Variables store values your program needs later.

let and const

Use const for values that should not be reassigned and let for values that can change. Beginners should avoid var while learning modern JavaScript.

const quizTitle = "Career readiness quick check";
let score = 0;

Real-life example: A quiz title stays the same, but the score changes as answers are checked.

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
let and constThe main idea in this part of the lessonIt gives you one building block for the final projectconst
exampleA small sample that shows the ideaIt helps you see how the concept looks in practiceconst
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

Which value should use let: quiz title or current score?

Mini-project task

Create variables for quiz title, learner name and starting score.

Strings, numbers, booleans, null and undefined

JavaScript values can be text, numbers, true/false values or empty placeholders.

const learnerName = "Aisha";
const totalQuestions = 5;
const hasFinished = false;
let savedResult = null;

Beginner mistake to avoid

Do not put numbers in quotes if you need to calculate with them.

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
Strings, numbers, booleans, null and undefinedThe main idea in this part of the lessonIt gives you one building block for the final projectconst learnerName = "Aisha"; const totalQuestions =...
exampleA small sample that shows the ideaIt helps you see how the concept looks in practiceconst learnerName = "Aisha"; const totalQuestions =...
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

Write one string, one number and one boolean for a quiz result.

Mini-project task

Add total questions and finished status variables to your quiz card plan.

Topic checkpoint

You now have the starter values for an interactive quiz result.

Topic 3

Operators and expressions

Expressions combine values to produce a result.

Correct answers->Calculation->Percentage

Arithmetic, comparison and logical operators

Use arithmetic for scores, comparisons for checks and logical operators when more than one condition matters.

const correctAnswers = 4;
const totalQuestions = 5;
const percentage = (correctAnswers / totalQuestions) * 100;
const passedPractice = percentage >= 60;

Real-life example: A readiness card calculates a percentage and checks whether it meets a practice threshold.

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
Arithmetic, comparison and logical operatorsThe main idea in this part of the lessonIt gives you one building block for the final projectconst correctAnswers = 4; const totalQuestions = 5;...
exampleA small sample that shows the ideaIt helps you see how the concept looks in practiceconst correctAnswers = 4; const totalQuestions = 5;...
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

Calculate the percentage for 3 correct answers out of 5.

Mini-project task

Create a percentage calculation for your quiz card.

Template literals

Template literals help place variables inside readable messages.

const message = `${learnerName}, your readiness score is ${percentage}%`;

Beginner mistake to avoid

Template literals use backticks, not normal quote marks.

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
Template literalsThe main idea in this part of the lessonIt gives you one building block for the final projectconst message = `${learnerName}, your readiness sco...
exampleA small sample that shows the ideaIt helps you see how the concept looks in practiceconst message = `${learnerName}, your readiness sco...
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

Write a message that includes a learner name and score.

Mini-project task

Create the result sentence your quiz card will display.

Topic checkpoint

You can calculate a readiness percentage and turn it into a readable message.

Topic 4

Conditions

Conditions let your program choose different messages based on a score.

Score->Decision->Feedback

if, else if and else

Use bands to convert a number into a clear readiness message.

let status = "";

if (percentage >= 80) {
  status = "Ready to practise";
} else if (percentage >= 50) {
  status = "Building";
} else {
  status = "Beginner";
}

Real-life example: A learner sees "Beginner", "Building" or "Ready to practise" after checking answers.

Beginner mistake to avoid

Use === for exact comparison, and avoid writing assignment = inside a condition by accident.

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
if, else if and elseThe main idea in this part of the lessonIt gives you one building block for the final projectlet status = ""; if (percentage >= 80) { status = "...
exampleA small sample that shows the ideaIt helps you see how the concept looks in practicelet status = ""; if (percentage >= 80) { status = "...
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

What status should 65% show?

Mini-project task

Add readiness feedback bands to your quiz card.

Topic checkpoint

Your project can now choose useful feedback based on a calculated score.

Topic 5

Loops

Loops repeat a task without copying the same code many times.

Start->Check answer->Update score->Repeat

for and for...of loops

A for loop can use an index. A for...of loop reads each item directly.

const answerScores = [1, 0, 1, 1, 0];
let correct = 0;

for (const answerScore of answerScores) {
  correct += answerScore;
}

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
for and for...of loopsThe main idea in this part of the lessonIt gives you one building block for the final projectfor
exampleA small sample that shows the ideaIt helps you see how the concept looks in practicefor
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

How many correct answers are in [1, 1, 0, 1]?

Mini-project task

Create an array of answer scores and loop through it to calculate correct answers.

while loops and infinite-loop warning

A while loop repeats while a condition is true. Make sure something changes inside the loop so it can stop.

let attempts = 0;

while (attempts < 3) {
  attempts += 1;
}

Beginner mistake to avoid

A loop that never changes its condition can freeze the browser tab.

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
while loops and infinite-loop warningThe main idea in this part of the lessonIt gives you one building block for the final projectwhile
exampleA small sample that shows the ideaIt helps you see how the concept looks in practicewhile
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

What line makes the example loop stop?

Mini-project task

Write one rule for limiting quiz attempts later.

Topic checkpoint

You can process multiple answers without writing a separate line for each one.

Topic 6

Arrays

Arrays store ordered lists of values.

0 HTML1 CSS2 JavaScript

Question lists and index positions

Arrays start at index 0. Use arrays for quiz questions, answer scores and selected skills.

const questions = [
  "What does JavaScript add to a page?",
  "Which keyword creates a value that should not change?"
];

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
Question lists and index positionsThe main idea in this part of the lessonIt gives you one building block for the final projectconst questions = [ "What does JavaScript add to a ...
exampleA small sample that shows the ideaIt helps you see how the concept looks in practiceconst questions = [ "What does JavaScript add to a ...
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

What is the first index in a JavaScript array?

Mini-project task

Store three readiness quiz questions in an array.

push, length, includes, forEach and map

Array methods help add items, count items and process values.

questions.push("What does querySelector do?");
console.log(questions.length);
questions.forEach((question) => console.log(question));

Beginner mistake to avoid

Do not confuse the item value with its index position.

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
push, length, includes, forEach and mapThe main idea in this part of the lessonIt gives you one building block for the final projectquestions.push("What does querySelector do?"); cons...
exampleA small sample that shows the ideaIt helps you see how the concept looks in practicequestions.push("What does querySelector do?"); cons...
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

Add one more question to a questions array.

Mini-project task

Use forEach to preview your quiz questions in the console.

Topic checkpoint

Your quiz card now has a question list and answer data.

Topic 7

Functions

Functions package reusable actions.

Input score->Function->Feedback

Function declarations, parameters and return values

A parameter receives input. A return value sends the result back.

function getReadinessFeedback(percentage) {
  if (percentage >= 80) return "Ready to practise";
  if (percentage >= 50) return "Building";
  return "Beginner";
}

Real-life example: The same function can be reused whenever a quiz result changes.

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
Function declarations, parameters and return valuesThe main idea in this part of the lessonIt gives you one building block for the final projectfunction getReadinessFeedback(percentage) { if (per...
exampleA small sample that shows the ideaIt helps you see how the concept looks in practicefunction getReadinessFeedback(percentage) { if (per...
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

What value does this function return for 45?

Mini-project task

Create a function that returns readiness feedback from a percentage.

Topic checkpoint

Your project has reusable logic instead of repeated condition blocks.

Topic 8

Objects

Objects store labelled values as key-value pairs.

learnerAisha

score80

statusReady

Learner profiles and quiz result objects

An object groups related values so the result is easier to pass around.

const quizResult = {
  learner: "Aisha",
  percentage: 80,
  status: "Ready to practise"
};

Beginner mistake to avoid

Use commas between object properties, but not after the final property if your team prefers cleaner style.

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
Learner profiles and quiz result objectsThe main idea in this part of the lessonIt gives you one building block for the final projectconst quizResult = { learner: "Aisha", percentage: ...
exampleA small sample that shows the ideaIt helps you see how the concept looks in practiceconst quizResult = { learner: "Aisha", percentage: ...
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

Add a date property to the object.

Mini-project task

Create a quizResult object for your readiness card.

Topic checkpoint

Your project can store a complete result in one structured object.

Topic 9

DOM, events and localStorage

These browser features connect your data to the page.

DOM basics

The DOM means the browser's live map of the HTML page. JavaScript uses that map to find elements, read values and update what the learner sees.

Use querySelector, textContent, classList and input values to update the page.

HTML element->JavaScript selects it->Content changes
const resultText = document.querySelector("#resultText");
resultText.textContent = "Ready to practise";

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
DOM basicsThe main idea in this part of the lessonIt gives you one building block for the final projectquerySelector
exampleA small sample that shows the ideaIt helps you see how the concept looks in practicequerySelector
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

Which selector would target an element with id="score"?

Mini-project task

Plan the HTML ids for your score and feedback text.

Events

An event means something the user or browser does, such as a click, key press or input change. Events let JavaScript respond at the right time.

User clicks->Event runs->Result appears
const checkButton = document.querySelector("#checkButton");

checkButton.addEventListener("click", function () {
  resultText.textContent = "Result calculated";
});

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
EventsThe main idea in this part of the lessonIt gives you one building block for the final projectconst checkButton = document.querySelector("#checkB...
exampleA small sample that shows the ideaIt helps you see how the concept looks in practiceconst checkButton = document.querySelector("#checkB...
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

What event should run when a learner presses the quiz button?

Mini-project task

Make a button trigger your readiness feedback function.

localStorage basics

localStorage saves small browser-side values. It is not an account, backend or database.

localStorage.setItem("latestQuizResult", JSON.stringify(quizResult));

const saved = localStorage.getItem("latestQuizResult");
const parsedResult = JSON.parse(saved);

Beginner mistake to avoid

Save objects with JSON.stringify and read them with JSON.parse.

Why this matters: It helps you make the Interactive Readiness Quiz Card respond to the user.

How to understand this example: Read it from top to bottom. First notice the key word, then notice the value, element or result it controls.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
localStorage basicsThe main idea in this part of the lessonIt gives you one building block for the final projectlocalStorage
exampleA small sample that shows the ideaIt helps you see how the concept looks in practicelocalStorage
mini-project taskA small build step after the exerciseIt turns the lesson into part of the Interactive Readiness Quiz CardInteractive Readiness Quiz Card

Quick exercise

Why is localStorage not the same as a database?

Mini-project task

Save the latest readiness result locally in the browser.

Topic checkpoint

Your quiz card can now update the page from a click and save a simple local result.

Final mini project

Interactive Readiness Quiz Card

This project combines variables, data types, operators, conditions, loops, arrays, functions, objects, DOM selection, events and simple localStorage.

<section class="quiz-card">
  <h2 id="quizTitle">Readiness quick check</h2>
  <p id="scoreText">Score waiting...</p>
  <p id="feedbackText">Click the button to calculate your result.</p>
  <button id="checkButton">Check result</button>
</section>
const learnerName = "Aisha";
const answerScores = [1, 0, 1, 1, 0];
const scoreText = document.querySelector("#scoreText");
const feedbackText = document.querySelector("#feedbackText");
const checkButton = document.querySelector("#checkButton");

function calculatePercentage(scores) {
  let correct = 0;

  for (const score of scores) {
    correct += score;
  }

  return (correct / scores.length) * 100;
}

function getReadinessFeedback(percentage) {
  if (percentage >= 80) return "Ready to practise";
  if (percentage >= 50) return "Building";
  return "Beginner";
}

checkButton.addEventListener("click", function () {
  const percentage = calculatePercentage(answerScores);
  const status = getReadinessFeedback(percentage);

  const quizResult = {
    learner: learnerName,
    percentage,
    status
  };

  scoreText.textContent = `${learnerName}, your score is ${percentage}%`;
  feedbackText.textContent = status;
  localStorage.setItem("latestQuizResult", JSON.stringify(quizResult));
});

How it works

The button click runs a function, calculates the score, chooses feedback, updates text on the page and saves the latest result in the browser.

Upgrade ideas

  • Add more questions
  • Add skill categories
  • Save progress
  • Show previous attempts
  • Add a reset button

Next step

Use JavaScript in your roadmap

Continue with HTML and CSS foundations, then use the Career Path Guide to connect JavaScript practice to real roles.