Middle School

Functions, arrays and objects: the big three. Three grades, Grades 6 to 8, with nine lessons in all.

Start learning

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

Grade 6

Functions: reusable recipes

Three lessons, then a test against Buggsy.

What you’ll learn

  • A function is a named, reusable block of code: function greet() { … }. Call it with greet().
  • Parameters are the placeholders in the definition; arguments are the real values you pass in.
  • return sends a value back and stops the function. No return means you get undefined.
  • Default parameters: function greet(name = "friend") { … }.
  • Function expressions: const add = function (a, b) { … };
  • Arrow functions: const add = (a, b) => a + b;
  • Functions are values: you can pass them into other functions (callbacks).

The lessons

  1. Declaring and calling Write code once, use it again and again.
  2. Return values Functions that give an answer back, and default parameters.
  3. Arrow functions and callbacks Shorter ways to write functions, and passing functions around.

Read the Grade 6 course notes

Grade 7

Arrays: lists of things

Three lessons, then a test against Buggsy.

What you’ll learn

  • An array is an ordered list: const fruits = ["mango", "papaya"];
  • Indexes start at 0: fruits[0]. The last item is fruits[fruits.length - 1] or fruits.at(-1).
  • push/pop add and remove at the end; unshift/shift at the start.
  • includes, indexOf and find search; slice copies a part; splice changes the array.
  • for…of loops over items. split turns a string into an array; join does the reverse.
  • Arrays are shared by reference: copy with [...arr].
  • sort() sorts as text! For numbers use arr.sort((a, b) => a - b).

The lessons

  1. Lists and indexes Make lists, read items, and why we count from zero.
  2. Adding, removing and finding push, pop, shift, unshift, includes, indexOf, slice and splice.
  3. Looping, joining and sorting for…of, split and join, copying, sorting and lists inside lists.

Read the Grade 7 course notes

Grade 8

Objects: describing things

Three lessons, then a test against Buggsy.

What you’ll learn

  • An object groups related values as key: value pairs: { name: "Mia", age: 12 }.
  • Read with dot notation user.name or brackets user["name"] (brackets work with variables).
  • Add or change with =; remove with delete; check with "key" in obj.
  • A method is a function inside an object. this means “the object before the dot”.
  • Arrays of objects are how most real data looks.
  • for…in, Object.keys, Object.values and Object.entries loop over objects.
  • Destructuring: const { name, age } = user;. Objects are shared by reference: copy with { ...obj }.

The lessons

  1. Keys and values Create objects, read and change their properties.
  2. Methods and nested data Functions inside objects, a first look at this, and arrays of objects.
  3. Looping, destructuring and copying for…in, Object.keys and entries, shortcuts, and the reference trap.

Read the Grade 8 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