Elementary School

Variables, data types, operators, decisions and loops. Five grades, Grades 1 to 5, with fifteen lessons in all.

Start learning

Everyone starts in Kiddie School and works up to here, one grade at a time.

Grade 1

Variables: boxes with labels

Three lessons, then a test against Buggsy.

What you’ll learn

  • A variable is a named box that holds a value: let age = 25;
  • = means put into (assignment), not “equals”.
  • Use let only the first time. After that, just use the name: age = 26;
  • const makes a locked box that can’t be reassigned. Use it by default.
  • Avoid var: it’s the old way, with confusing rules.
  • Names can use letters, digits, _ and $, can’t start with a digit, and are case-sensitive. Use camelCase.
  • A variable that was declared but never given a value is undefined.

The lessons

  1. Boxes with labels Teach your program to remember things with let.
  2. const, var and good names Locked boxes, Grandpa’s old box, and the rules for naming.
  3. Variables working together undefined, math with boxes, updating values and the swap puzzle.

Read the Grade 1 course notes

Grade 2

Data types: what’s in the box?

Three lessons, then a test against Buggsy.

What you’ll learn

  • Strings are text in quotes: "hi", 'hi' or ` hi `.
  • Template literals use backticks and ${ } to drop values into text.
  • .length, [index] and methods like .toUpperCase(), .includes() and .slice() work on strings.
  • Numbers include NaN (not a number) and Infinity. 0.1 + 0.2 isn’t exactly 0.3!
  • Booleans are true or false.
  • undefined means “not set yet”; null means “deliberately empty”.
  • typeof tells you a value’s type. Number(), String() and Boolean() convert between types.

The lessons

  1. Strings and template literals Text in quotes, escape characters, and the easy way to build sentences.
  2. String superpowers length, indexes and the most useful string methods.
  3. Numbers, booleans and nothing NaN, Infinity, true and false, undefined vs null, typeof and conversions.

Read the Grade 2 course notes

Grade 3

Operators: math, comparisons and logic

Three lessons, then a test against Buggsy.

What you’ll learn

  • Math: + - * /, remainder %, power . Brackets first, then , then * / %, then + -.
  • Shortcuts: x += 5, x -= 2, x *= 3, x++, x--.
  • Comparisons give booleans: > < >= <=.
  • Always use === and !==. The loose == converts types and causes surprises.
  • Logic: && (and), || (or), ! (not).
  • Math.round, Math.floor, Math.ceil, Math.max, Math.min and Math.random().
  • A random whole number from 1 to 6: Math.floor(Math.random() * 6) + 1.

The lessons

  1. Math class is back Arithmetic, remainders, powers, order of operations and shortcuts.
  2. Comparisons and equality Bigger, smaller, equal, and why === beats ==.
  3. Logic and the Math object AND, OR, NOT, rounding and random numbers.

Read the Grade 3 course notes

Grade 4

Making decisions

Three lessons, then a test against Buggsy.

What you’ll learn

  • if (condition) { … } runs code only when the condition is true.
  • else is the backup plan; else if adds more choices. The first true branch wins.
  • Falsy values: false, 0, "", null, undefined, NaN. Everything else is truthy.
  • Combine conditions with && and ||, and nest ifs inside ifs.
  • The ternary condition ? a : b is a one-line if/else that gives back a value.
  • switch compares one value against many cases. Don’t forget break!

The lessons

  1. if, else and else if Let your program choose what to do.
  2. Truthy, falsy and combining Values that act like true or false, and smarter conditions.
  3. Ternaries and switch One-line decisions, and picking from a menu of cases.

Read the Grade 4 course notes

Grade 5

Loops: doing things again and again

Three lessons, then a test against Buggsy.

What you’ll learn

  • while (condition) { … } repeats while the condition is true.
  • If the condition never becomes false, you get an infinite loop.
  • for (let i = 0; i < 5; i++) { … } is the counting loop: start, condition, step.
  • The accumulator pattern: start a total at 0 and add to it inside the loop.
  • do…while always runs at least once.
  • break exits the loop; continue skips to the next round.
  • for (const char of "hello") loops over each character (or each item of an array).

The lessons

  1. while and for Make the computer repeat itself without getting tired.
  2. Loop patterns Accumulators, do…while, break and continue.
  3. Strings, nested loops and FizzBuzz Loop over text, put loops inside loops, and beat the classic interview question.

Read the Grade 5 course notes

Class starts whenever you’re ready

Every lesson is free, there’s nothing to sign up for, and your progress saves as you go.

Start learning