Skip to content
Back to Hub
6 lessons
Start Here

Foundations

Before you write code, you need to understand the building blocks. These 6 lessons take you from “what is a computer?” to writing your first program.

Lesson 1 of 6

What is a Computer?

A computer is a machine that follows instructions very, very fast. It has three main parts:

The CPU (processor) is the brain — it does the thinking and calculating. Memory (RAM) is the short-term notepad — it holds what the computer is working on right now. Storage (hard drive or SSD) is the filing cabinet — it saves things permanently, even when the computer is turned off.

Think of it like cooking: the CPU is the chef, memory is the counter space where ingredients sit while you cook, and storage is the pantry where everything is kept.

how-a-computer-works.txt
1// Think of a computer like a kitchen: 2 3CPUThe chef (does the work) 4MemoryThe counter (temporary workspace) 5StorageThe pantry (permanent storage) 6 7// When you open an app: 8// 1. Storage sends the app to Memory 9// 2. CPU reads instructions from Memory 10// 3. CPU executes them one by one — millions per second!
What you learned
  • CPU processes instructions (the brain)
  • Memory (RAM) stores data temporarily while working
  • Storage saves data permanently (files, photos, apps)
Next: What is Software?
Lesson 2 of 6

What is Software?

Software is a set of instructions that tells the computer what to do. Without software, a computer is just an expensive box.

There are two main kinds: the operating system (like Windows, macOS, or Android) which manages everything, and applications (like Instagram, Chrome, or Minecraft) which are programs you use for specific tasks.

All software starts as code — text written by a human in a programming language. The computer translates that text into actions.

hello-world.js
1// Code is just instructions written in a language 2// the computer can understand. 3 4// This is JavaScript — one of the most popular languages: 5console.log("Hello, world!"); 6 7// When you run this, the computer: 8// 1. Reads the instruction 9// 2. Understands "console.log" means "print to screen" 10// 3. Displays: Hello, world!
What you learned
  • Software = instructions for the computer
  • Operating systems manage the computer; apps do specific tasks
  • All software starts as code written by humans
Next: What is a Variable?
Lesson 3 of 6

What is a Variable?

A variable is a named container that holds a piece of data. Think of it like a labeled box — the label is the name, and whatever is inside is the value.

You can store text (called strings), numbers, true/false values (called booleans), and more. You can also change what is inside the box at any time.

Variables are the building blocks of every program. Without them, the computer would have no way to remember anything while it runs your code.

variables.js
1// Creating variables — like labeling boxes 2let name = "Fatima"; 3let age = 14; 4let lovesToCode = true; 5 6// You can use them: 7console.log("My name is " + name); 8// Output: My name is Fatima 9 10// You can change them: 11age = 15; 12console.log(name + " is now " + age); 13// Output: Fatima is now 15
What you learned
  • Variables are named containers for data
  • Strings hold text, numbers hold numbers, booleans hold true/false
  • You can read, use, and change variables at any time
Next: What is Logic?
Lesson 4 of 6

What is Logic?

Logic is how your program makes decisions. Just like you decide "if it is raining, take an umbrella," code uses if/else statements to choose what to do.

The computer checks a condition — something that is either true or false — and runs different code depending on the answer.

This is what makes programs smart. Without logic, every program would do the exact same thing every time, no matter what.

logic.js
1let age = 14; 2 3// The computer checks: is age >= 13? 4if (age >= 13) { 5 console.log("You can learn to code!"); 6} else { 7 console.log("You're almost there!"); 8} 9// Output: You can learn to code! 10 11// You can check multiple things: 12let score = 85; 13 14if (score >= 90) { 15 console.log("Amazing!"); 16} else if (score >= 70) { 17 console.log("Great job!"); 18} else { 19 console.log("Keep practicing!"); 20} 21// Output: Great job!
What you learned
  • if/else lets your program make decisions
  • Conditions are checked as true or false
  • You can chain multiple checks with else if
Next: What is a Function?
Lesson 5 of 6

What is a Function?

A function is a reusable block of code that does a specific job. Instead of writing the same steps over and over, you write them once inside a function and then call it whenever you need it.

Functions can take inputs (called parameters) and give back an output (called a return value). Think of a function like a recipe: you give it ingredients, it follows the steps, and it gives you a finished dish.

Every real program is built from functions. They keep your code organized, shorter, and easier to understand.

functions.js
1// Define a function — write the recipe once 2function greet(name) { 3 return "Hello, " + name + "!"; 4} 5 6// Call it — use the recipe anytime 7console.log(greet("Fatima")); 8// Output: Hello, Fatima! 9 10console.log(greet("Omar")); 11// Output: Hello, Omar! 12 13// Functions can do calculations too 14function add(a, b) { 15 return a + b; 16} 17 18console.log(add(5, 3)); 19// Output: 8
What you learned
  • Functions are reusable blocks of code
  • They take inputs (parameters) and return outputs
  • Write once, call many times — keeps code clean
Next: Your First Program
Lesson 6 of 6

Your First Program

Now let us put everything together. You know what variables, logic, and functions are — time to build a real (tiny) program.

This program creates a student profile, checks if they are old enough to join a coding club, and prints a personalized welcome message. It uses every concept you have learned so far.

Read through the code below. If you can understand what each line does, you are ready for the next track.

first-program.js
1// Your first real program! 2 3// 1. Variables — store data 4let studentName = "Fatima"; 5let studentAge = 14; 6let favoriteSubject = "Science"; 7 8// 2. Function — reusable greeting 9function welcomeMessage(name, subject) { 10 return "Welcome, " + name + "! " + 11 "We hear you love " + subject + "."; 12} 13 14// 3. Logic — make a decision 15if (studentAge >= 13) { 16 console.log(welcomeMessage(studentName, favoriteSubject)); 17 console.log("You're in the Coding Club!"); 18} else { 19 console.log("Come back when you're 13!"); 20} 21 22// Output: 23// Welcome, Fatima! We hear you love Science. 24// You're in the Coding Club!
What you learned
  • Variables store your data
  • Functions organize your logic into reusable pieces
  • if/else makes your program respond to different situations
  • Real programs combine all three — and that is exactly what you just read
Next Track: Build Your First Website