Learn the basics (quick lessons)
Use this page in two ways:
- Teach: read the lesson + show examples.
- Practice: students answer questions, then click Check Answers.
Tip: Open the browser DevTools console (often F12) and try examples using console.log().
1) Variables: var, let, const
let creates a block-scoped variable you can change. const creates a block-scoped variable you cannot reassign.
let score = 0;
score = score + 1; // OK
const name = "Aylin";
// name = "Sam"; // Not allowed (reassignment)
2) Data types (beginner)
- string → text like "Hello"
- number → 10, 3.14
- boolean → true / false
- undefined → declared but not assigned
- null → intentional “no value”
typeof "Hello" // "string"
typeof 10 // "number"
typeof true // "boolean"
let x; // x is undefined
let y = null; // y is null
3) Operators
=== checks value + type. (Recommended for beginners.)
2 == "2" // true (value only)
2 === "2" // false (value + type)
4) Arrays
An array is an ordered list. Use push() to add to the end and pop() to remove from the end.
let nums = [1, 2, 3];
nums.push(4); // [1,2,3,4]
nums.pop(); // [1,2,3]
5) Loops
for is great when you know how many times to repeat. while repeats while a condition is true.
for (let i = 0; i < 3; i++) {
console.log(i);
}
let n = 3;
while (n > 0) {
console.log(n);
n--;
}
6) Functions
A function is a reusable block of code. return stops the function and sends a value back.
function add(a, b) {
return a + b;
}
let result = add(2, 3); // 5
7) DOM basics (browser)
const title = document.getElementById("title");
title.textContent = "Hello!";
Teaching controls
How scoring works
Each section shows a score when you click Check Answers. Use Reset for a new attempt.
Beginner reminders
- === compares value + type.
- push() add end, pop() remove end.
- length is number of items.
Section A — Multiple Choice
Choose one correct answer for each question.
Section B — True / False
Choose True (T) or False (F).
Section C — Matching
Match 1–20 with A–T (choose the letter).