seSHion

Choose a lesson

Chapter 1JavaScript Fundamentals
1.1Software Lifecycle
Slides

1.1.1 Slides: Foundations

Unit 1.1 slides: software lifecycle, umbrella activities, task sets, SDLC methodologies, and the four Ps. Shown from a copy of the bookSHelf deck kept in this site.

Reading

1.1.2 Reading: Console: console.log & sequential execution

Week 1

How to print values with console.log and how JavaScript runs code top-to-bottom. Read before the A1.2 console lab.

Assignment

1.1.3 Your First Statement

Open the browser console, run five ready-made statements, then change two of them to print your own text. Auto-graded.

Assignment

1.1.4 What a Program Is

Week 1

Learn what a program is, then write six lines of JavaScript with console.log(): text, math, joined strings and a true/false comparison, and watch them run in order.

Video

1.1.5 Video: What is the SDLC?

A ~6-minute overview of the whole software development lifecycle. Watch before The Four Phases reading so you can see the shape of a project before naming its parts.

Reading

1.1.6 Reading: The Four Phases

Read about process models and the four framework activities before you classify project tasks in the next lab.

Assignment

1.1.7 Classify the Task

Read each task from a school-lunch app and log which of the four phases it belongs to. Auto-graded.

Worked Example

1.1.8 Worked Example: Greeting App Through Four Phases

Reading

1.1.10 Reading: Umbrella Activities

Read about umbrella activities: the work that runs alongside every phase, before the Name That Umbrella lab.

Assignment

1.1.11 Name That Umbrella

Read a testing scenario and log which umbrella activity it belongs to. Auto-graded.

Reading

1.1.12 Reading: Software Engineering Actions

Read about software engineering actions: the named jobs inside a phase, before you write a task set.

Reading

1.1.13 Reading: Task Sets

Read about task sets: the checklist one action needs, before you write a task set of your own.

Worked Example

1.1.14 Worked Example: Task Set for a Loop Bug

Assignment

1.1.15 Write a Task Set

List a task set for the requirements-definition action. AI-graded with hints.

Reading

1.1.16 Reading: SDLC Methodologies

Read about SDLC methodologies and why teams follow one, before the Four Ps reading.

Reading

1.1.17 Reading: The Four Ps

Read about the four Ps and why two projects elaborate the same framework differently.

Quiz

1.1.18 Same Framework, Different Weight

Five multiple-choice questions on the four Ps and why two teams elaborate the same framework differently. Checked instantly.

Reading

1.1.19 Reading: Prescriptive Process Models

Read about prescriptive process models: an orderly, prescribed sequence, before the reading on where they break.

Reading

1.1.20 Reading: Where Prescriptive Models Break

Read about where prescriptive models break: rigid, inflexible, and poor fits for changing requirements.

Quiz

1.1.21 Does It Fit?

Four multiple-choice questions on prescriptive process models and where they break. Checked instantly.

Assignment

1.1.22 Describe the Lifecycle

Describe the four framework activities, walk a real product through them, and map them onto the five-phase naming. AI-graded with hints.

Quiz

1.1.23 Unit 1.1 Quiz

Week 3

Ten multiple-choice questions on the four phases, umbrella activities, actions and task sets, the four Ps, and prescriptive models. Checked instantly.

→ View full module page
1.2Variables and Data Types
Slides

1.2.1 Slides: Variables and Data Types

Variables and Data Types slides.

Reading

1.2.2 Reading: Declaring Variables with let and const

Declare variables with let and const, reassign a let, and choose between the two. Read before the variables-and-types lesson.

Reading

1.2.3 Reading: Every Value Has a Type

Eight types, and the whole language is built from them. The map before the tour.

Reading

1.2.4 Reading: Dynamically Typed

A variable is not locked to one type. Convenient, and the reason a whole class of bug only shows up when you run the code.

Assignment

1.2.5 Change the Type

Give one variable three different types in a row and print what typeof says each time. Auto-graded.

Reading

1.2.6 Reading: The number Type

Whole numbers and decimals are the same type in JavaScript. One type, not two.

Reading

1.2.7 Reading: Arithmetic Operators and Type Coercion

Learn arithmetic operators and the biggest JS beginner trap: why "5" + 3 equals "53". Read before the operators-expressions lesson.

Reading

1.2.8 Reading: Infinity, -Infinity and NaN

Three values that are numbers without being numbers. Definition 1.2.1, and why JavaScript never crashes on bad maths.

Worked Example

1.2.9 Worked Example: NaN Is Sticky

Once NaN appears in a calculation it spreads to the whole result. Example 1.2.1, with the one exception.

Assignment

1.2.10 Predict the Number

Four expressions. Write down what you expect, then run them and find out. Auto-graded.

Reading

1.2.11 Reading: BigInt

Past 9007199254740991, ordinary numbers stop being exact. Definition 1.2.2 and the n suffix.

Reading

1.2.12 Reading: Strings and the Three Quotes

Double, single and backtick. Two of them are interchangeable and one is not. Definition 1.2.3.

Reading

1.2.13 Reading: Embedding Values with ${...}

Drop a variable or a whole calculation into the middle of a string. Backticks only.

Reading

1.2.14 Reading: String Methods in Practice

Build strings with backtick template literals and use .length, .toUpperCase(), and .includes(). Read before the variables-and-types lesson.

Assignment

1.2.15 Greeting with Backticks

Build a greeting with a template literal, then prove single quotes cannot do the same job. Auto-graded.

Assignment

1.2.16 Operators and Expressions Check

Practice arithmetic, string concatenation, and comparison operators.

Reading

1.2.17 Reading: The boolean Type

Exactly two values, and most of them come out of a comparison rather than being typed by hand. Definition 1.2.4.

Worked Example

1.2.18 Worked Example: Comparisons Produce Booleans

Four comparisons, four boolean answers, and the habit of reading a comparison as a value.

Reading

1.2.19 Reading: The null Value

Deliberately nothing. A type with exactly one value in it. Definition 1.2.5.

Reading

1.2.20 Reading: The undefined Value

What JavaScript puts in a variable you declared but never filled. Definition 1.2.6, and why not to write it yourself.

Assignment

1.2.21 null vs undefined

Tell the two empties apart and say when you'd write each. AI-graded with hints.

Reading

1.2.22 Reading: Primitive vs Object

Seven types hold one thing each. The eighth holds collections. Definition 1.2.7.

Reading

1.2.23 Reading: The typeof Operator

Ask any value what type it is. Definition 1.2.8, and the syntax that looks like a function but isn't one.

Worked Example

1.2.24 Worked Example: The typeof Surprises

Three answers that need explaining, including a bug the language has kept on purpose since 1995.

Assignment

1.2.25 typeof Round-Up

Run typeof over six different values and find the one answer that lies. Auto-graded.

Assignment

1.2.26 Variables and Types Check

Understand how to store and work with data using let, const, and typeof.

Reading

1.2.27 Reading: The Seven Primitives, Recapped

The whole type system on one page, now that you have met every row of it.

Assignment

1.2.28 Fix Ten Declarations

Ten broken variable declarations. Fix each one and say in a comment what was wrong. Auto-graded.

Assignment

1.2.29 Describe a Real Object

Six variables describing something in the room, printed as a sentence with a template literal. Auto-graded.

Video

1.2.30 Video: Every Value Has a Type

A four-minute tour of the whole type system: eight basic types, seven of them primitive, dynamic typing, and the typeof operator, including the one answer typeof gets wrong. Watch after the readings as a second pass over the same ground.

Quiz

1.2.31 Module 1.2 Quiz

Eight multiple-choice questions on dynamic typing, the seven primitives, and null vs undefined. Checked instantly.

→ View full module page
1.3Documentation and Coding Conventions
Slides

1.3.1 Slides: Documentation and Coding Conventions

Documentation and Coding Conventions slides.

Reading

1.3.2 Reading: camelCase and const

Write every variable name in camelCase, mark never-changing values with const, and see why descriptive names beat short mystery names.

Reading

1.3.3 Reading: Code Layout

Apply consistent indentation, operator spacing, and semicolons so code is easy to scan.

Reading

1.3.4 Reading: Comments: // and /* */

What single-line and block comments do, and why they matter. Read before A3.1.

Reading

1.3.5 Reading: Why Documentation Matters

Why comments and READMEs matter once more than one person touches the code.

Reading

1.3.6 Reading: Human-Readable Names

A name should say what it holds without needing a comment. Definition 1.3.1, first rule.

Reading

1.3.7 Reading: Avoid Single Letters and Abbreviations

A single letter tells the reader nothing. Definition 1.3.1, second rule, and the one exception.

Reading

1.3.8 Reading: Descriptive but Concise

data and value are too vague to help anyone. Definition 1.3.1, third rule, and the other ditch.

Reading

1.3.9 Reading: Agree on Terms

If the team says "user", never write "visitor". Definition 1.3.1, fourth rule: the one that only bites in groups.

Worked Example

1.3.10 Worked Example: Good vs Bad Names

Three lines, twice. Nothing about how it runs changes, only how fast a reader understands it. Example 1.3.1.

Assignment

1.3.11 Rename the Mystery Variables

Two snippets of single-letter code. Rename every variable so each line explains itself. Auto-graded.

Assignment

1.3.12 Rate These Names

Six names, and one that is genuinely borderline. Judge each and say which rule it breaks. AI-graded with hints.

Reading

1.3.13 Reading: Reuse or Create?

A box labelled "books" that you keep putting shoes in. Book §1.3.2, and the habit to break early.

Reading

1.3.14 Reading: What Reuse Actually Costs

It saves a little typing and buys you a debugging problem. Also: extra variables do not slow your program down.

Worked Example

1.3.15 Worked Example: One Variable, Three Meanings

Walk a reused variable line by line, then split it. Try It Now 1.3.2, done out loud.

Assignment

1.3.16 Split the Reused Variable

One variable doing four jobs. Give each job its own well-named variable. Auto-graded.

Assignment

1.3.17 Team Vocabulary

Your teammate wrote cartItems. You wrote basketItems. Say what the problem is and what you do about it. AI-graded with hints.

Reading

1.3.18 Reading: What a README Is For

The one file written for someone who has not read your code yet. Three questions it has to answer.

Assignment

1.3.19 Document a Messy Program

Twelve lines with no comments, no spacing and terrible names. Fix it to the class style guide and write the README. Auto-graded.

Video

1.3.20 Video: Names Are for Readers

Three minutes on why good variable names matter and why giving one variable several jobs costs more than it saves. Watch after the readings.

Quiz

1.3.21 Module 1.3 Quiz

Nine multiple-choice questions on naming, comments, documentation and READMEs. Checked instantly.

→ View full module page
1.4Programming Paradigms and Languages
Slides

1.4.1 Slides: Programming Paradigms and Languages

Programming Paradigms and Languages slides.

Reading

1.4.2 Reading: Why There Are So Many Languages

Languages are purpose driven. "Which is best?" is not a well-formed question: best for what?

Assignment

1.4.3 Match the Language to the Job

Four jobs, four languages. Log the language each job was designed for. Auto-graded.

Reading

1.4.4 Reading: Level of Abstraction

How much machine detail a language makes you handle, and why hiding it is a choice, not a shortcut.

Reading

1.4.5 Reading: High-Level and Low-Level Languages

One runs fast, one is written fast. Definition 1.4.1 and the trade-off behind it.

Quiz

1.4.6 Which Level Fits?

Five multiple-choice questions on levels of abstraction and picking a language level against a deadline. Checked instantly.

Reading

1.4.7 Reading: What a Paradigm Is

Two programs can solve the same problem and be organised in completely different ways. Definition 1.4.2.

Reading

1.4.8 Reading: Procedural Programming

The style you have been writing since §1.2: steps in order, acting on data held somewhere else.

Reading

1.4.9 Reading: Structured Programming

Procedural programming with a discipline attached, and a surprisingly strong claim. Definition 1.4.3, and SLO-2.

Reading

1.4.10 Reading: Sequence, Selection, Repetition

The three structures every program is built from, one at a time, with where Chapter 2 teaches each.

Worked Example

1.4.11 Worked Example: Which Structures Does This Use?

Three programs, read one at a time, naming the structures in each. The identification habit, done out loud.

Assignment

1.4.12 Name the Structure

Four described programs. Log which of the three structures each one needs. Auto-graded.

Reading

1.4.13 Reading: Why goto Went Away

The first example in this course of a restriction being a feature. No arbitrary jumps, and what that buys.

Assignment

1.4.14 Three Structures, Three Examples

Name the three structures of structured programming and give an everyday example of each. AI-graded with hints.

Reading

1.4.15 Reading: Object-Oriented Programming

Bundling data with the behaviour that acts on it. Definition 1.4.4, and why Chapter 5 exists.

Worked Example

1.4.16 Worked Example: Procedural vs Object-Oriented

Two snippets, same output, different paradigm. What actually tells them apart is not what you'd guess.

Quiz

1.4.17 Where Does the Balance Live?

Five multiple-choice questions on where behaviour lives in procedural versus object-oriented style. Checked instantly.

Reading

1.4.18 Reading: Functional Programming

Same input, same output, nothing else disturbed. The paradigm that is careful about change.

Reading

1.4.19 Reading: JavaScript Is Multi-Paradigm

Some languages commit to one style. JavaScript supports all three, and real programs mix them.

Assignment

1.4.20 Sort the Snippet

Three snippets, three paradigms. Log which is which, then name what JavaScript itself is. Auto-graded.

Video

1.4.21 Video: Why Are There So Many Programming Languages?

A short survey of the language landscape. Watch after the readings, as a second pass over the same ground in someone else's words.

Quiz

1.4.22 Module 1.4 Quiz

Eight multiple-choice questions on purpose-driven languages, levels of abstraction, and the three paradigms. Checked instantly.

Assignment

1.4.23 Two Languages, Two Purposes

Pick two languages that aren't JavaScript and explain what each is for and why its paradigm fits. AI-graded with hints.

→ View full module page
1.5Program Design Tools and Environments
Slides

1.5.1 Slides: Program Design Tools and Environments

Program Design Tools and Environments slides.

Reading

1.5.2 Reading: Think Before You Type

A program has two separate difficulties. Typing solves one of them, and doing both at once is why you get stuck.

Reading

1.5.3 Reading: What Computational Thinking Is

The bridge between a problem and its solution. Definition 1.5.1, and why a computer cannot do this part for you.

Reading

1.5.4 Reading: The Four Cornerstones

Decomposition, pattern recognition, abstraction, algorithms, and the table analogy that explains why you need all four.

Reading

1.5.5 Reading: The Three As

Abstraction, automation, analysis: the shorter framing, and the step people skip.

Worked Example

1.5.6 Worked Example: The Jam Sandwich Robot

Five instructions, read back literally by something that knows nothing. Watch where they break.

Assignment

1.5.7 Instructions for a Robot

Write instructions for a task, then find the first one that breaks when read literally. AI-graded with hints.

Reading

1.5.8 Reading: Decomposition

Redefining one hard task as a set of easy ones. Definition 1.5.2.

Reading

1.5.9 Reading: Pattern Recognition

Categories are compression. Twelve unrelated facts become three groups you can hold.

Reading

1.5.10 Reading: Inductive and Deductive Reasoning

The two directions logical thinking runs, and where each one shows up when you are debugging.

Worked Example

1.5.11 Worked Example: Decomposing the Sandwich

Build Table 1.5.1 from nothing, and watch the empty columns tell you what you forgot.

Quiz

1.5.12 Decompose Getting to School

Five multiple-choice questions on decomposition and what makes a part self-contained. Checked instantly.

Reading

1.5.13 Reading: Abstraction

Keep what matters, discard the rest. Definition 1.5.3, and the one test that decides which is which.

Reading

1.5.14 Reading: Layers of Abstraction

Real systems stack abstractions so each layer minds its own job. You already trust dozens of them.

Worked Example

1.5.15 Worked Example: Computational Thinking in Chess

All four techniques on a problem nobody would call programming, which is the point.

Quiz

1.5.16 Keep Two, Drop Two

Five multiple-choice questions on abstraction, the drop test, and why it is relative to the problem. Checked instantly.

Assignment

1.5.17 Computational Thinking

Explain the four parts of computational thinking in your own words, with a worked example of each. AI-graded with hints.

Reading

1.5.18 Reading: What an Algorithm Is

Finite, ordered, unambiguous. Definition 1.5.4, and why all three words are doing work.

Reading

1.5.19 Reading: Pseudocode and Flowcharts

Two ways to write an algorithm down before you write any code: pseudocode in structured English, and a flowchart in three shapes.

Reading

1.5.20 Reading: The Two Pseudocode Rules

One instruction per line, and indent what is inside something else. Definition 1.5.5: that is the whole ruleset.

Worked Example

1.5.21 Worked Example: Pseudocode for a Decision

The voting check, planned before it is coded. Example 1.1, and what the plan deliberately does not say.

Worked Example

1.5.22 Worked Example: Butter or No Butter

The sandwich grows a decision, and pseudocode grows keywords: START, INPUT, IF, THEN, ELSE, OUTPUT.

Quiz

1.5.23 Spot the Broken Pseudocode

Five multiple-choice questions on reading a broken plan, indentation, and why nothing running it is the point. Checked instantly.

Quiz

1.5.24 Pseudocode: Largest of Three

Five multiple-choice questions on reading pseudocode plans: which is pseudocode, which plan is correct, and what makes a loop end. Checked instantly.

Reading

1.5.25 Reading: The Three Flowchart Shapes

Oval, rectangle, diamond. Definition 1.5.6, and Table 1.5.2: nearly every flowchart is these three.

Reading

1.5.26 Reading: The Diamond

One way in, two ways out, and the paths rejoin. This is §1.4's selection, drawn.

Reading

1.5.27 Reading: Pseudocode or Flowchart?

Neither is better. They are good at different things, and most programmers use both.

Console

1.5.28 Plain English to Pseudocode: Even or Odd

Turn plain-English steps into pseudocode: get a number, ask whether it is even, print one of two answers, then end. Your first pseudocode practice, ungraded.

Reading

1.5.29 Reading: The Class Plan Convention

The rule for the rest of the course: every graded build opens with a plan, and the plan goes first. What a plan looks like, what the checks can and cannot see, and how big a plan should get.

Assignment

1.5.30 Plan It in Pseudocode (Part 1)

Plan the printer-credit rule in pseudocode with the keywords from the reading: take in the pages, ask the question, charge only the pages over 20, and report both answers. The plan comes before the code in 1.5.31.

Assignment

1.5.31 Implement Your Plan (Part 2)

Turn the plan you just wrote into working JavaScript, and confirm the code matches the plan. Auto-graded.

Reading

1.5.32 Reading: Sequential, Parallel, Concurrent

Three ways the same instructions can be carried out, and why two of them finish sooner.

Reading

1.5.33 Reading: Recursion and the Base Case

A process that calls itself on a smaller version of the same problem. Definition 1.5.7: read it, don't write it yet.

Worked Example

1.5.34 Worked Example: Stack Overflow on Purpose

Cause the error deliberately, so you recognise it when it happens by accident.

Reading

1.5.35 Reading: The Browser Console

F12, then Console. A scratchpad that forgets everything, which is exactly what makes it comfortable. Definition 1.5.8.

Reading

1.5.36 Reading: A Code Editor

The console is a scratchpad; the editor holds the program. The difference is permanence.

Assignment

1.5.37 Settle It in the Console

Two expressions, one pair of brackets, and a question answered in four seconds. Auto-graded.

Reading

1.5.38 Reading: Reading an Error Message

The kind, the detail, the place. Usually the most useful sentence available, and usually skimmed.

Assignment

1.5.39 Cause a ReferenceError on Purpose

Break it, read the three parts, say which one solved it, then fix it. Auto-graded.

Reading

1.5.40 Reading: Testing and Test Cases

You have to know what the answer should be before you can tell that it isn't.

Reading

1.5.41 Reading: Debugging with console.log

Most bugs never produce a message. Definition 1.5.9, and the two habits that make printing work.

Worked Example

1.5.42 Worked Example: Finding the Rectangle Bug

A program that prints 9 instead of 20, found by narrowing rather than by staring.

Assignment

1.5.43 Debug the Order Total

Three bugs, none of which produce an error message. Narrow them down with labelled prints. Auto-graded.

Video

1.5.44 Video: Think Before You Type

Three and a half minutes on the four cornerstones of computational thinking, the three words that define an algorithm, and when to reach for pseudocode versus a flowchart. Covers the design half of this module.

Quiz

1.5.45 Module 1.5 Quiz

Twelve multiple-choice questions on computational thinking, decomposition, abstraction, pseudocode, flowcharts, recursion and debugging. Checked instantly.

→ View full module page
1.6Chapter 1 Group Performance Assessment
1.7Chapter 1 Individual Performance Assessment
Chapter 2Control Flow
2.1Conditionals
Slides

2.1.1 Slides: Conditionals

Conditionals slides: if / else if / else, comparison operators, the logical operators && || !, and the ternary operator ?.

Video

2.1.2 Video: Making Decisions in Code

Week 5

A short tour of how programs choose a path with if/else. Watch before 2.1.3 Reading, If / Else if / Else.

Reading

2.1.3 Reading, If / Else if / Else

Week 5

Learn how to make your code choose a path: if, else if, and else. Read before the conditionals practice lesson.

Worked Example

2.1.4 Worked Example: Tracing an if/else chain

Week 5
Console

2.1.5 Plain English to Pseudocode: if / else

Week 5

Turn plain-English steps into pseudocode for an if/else: one question, two labelled answers, and a last line that runs either way.

Console

2.1.6 Write Your First if

Week 5

Write an if statement that logs a message when a number meets a threshold. Auto-graded.

Console

2.1.7 Add an else

Week 5

Extend an if statement with an else branch to handle both outcomes. Auto-graded.

Console

2.1.8 Chain Three Branches

Week 5

Write an else if chain with at least three branches. Auto-graded.

Reading

2.1.9 Reading: Nested Conditionals

Week 5

Learn how to put one if statement inside another to ask a follow-up question. Read before the nested-if practice lesson.

Worked Example

2.1.10 Worked Example: Nested if Inside if

Week 5
Console

2.1.11 Nest a Check

Week 5

Write an if statement inside another if statement to ask a follow-up question. Auto-graded.

Reading

2.1.12 Reading: Truthy and Falsy Values

Week 5

Learn the six falsy values and how if converts any value to true or false. Read before the truthy-check practice lesson.

Worked Example

2.1.13 Worked Example: Falsy Value Surprises

Week 5
Console

2.1.14 Guard with a Truthy Check

Week 5

Write an if statement that tests a variable directly, relying on truthy/falsy conversion. Auto-graded.

Reading

2.1.15 Reading: Comparison Operators & === vs ==

Week 5

Learn the six comparison operators and why === is safer than ==. Read before the conditionals practice lesson.

Worked Example

2.1.16 Worked Example: What each comparison returns

Week 5
Console

2.1.17 Predict, Then Run

Week 5

Log four comparison expressions, including at least one ===, and observe the results. Auto-graded.

Worked Example

2.1.18 Worked Example: One Equals Sign, or Three?

Week 5
Console

2.1.19 Count the Equals Signs

Week 5

Fix an if condition that uses a single = where it should compare with ===. Auto-graded.

Reading

2.1.20 Reading: The Conditional Operator ?

Week 5

Learn the ternary operator: condition ? value1: value2. Read before the ternary practice lesson.

Worked Example

2.1.21 Worked Example: Ticket Price with ?

Week 5
Console

2.1.22 Write Your First Ternary

Week 5

Use the conditional operator ? to assign one of two values to a variable. Auto-graded.

Reading

2.1.23 Reading: Chaining Multiple ? Operators

Week 5

Learn how to chain conditional operators to pick from more than two values. Read before the chained-ternary practice lesson.

Worked Example

2.1.24 Worked Example: Size Label with Chained ?

Week 5
Console

2.1.25 Chain Your Ternaries

Week 5

Chain at least two conditional operators to pick from three or more values. Auto-graded.

Reading

2.1.26 Reading: When to Use ? vs if

Week 5

Learn the rule of thumb: use ? to pick a value, use if to run different code. Read before the rewrite practice lesson.

Worked Example

2.1.27 Worked Example: Rewriting a Misused Ternary

Week 5
Console

2.1.28 Rewrite It as if/else

Week 5

Take a ternary used for its side effect and rewrite it as an if/else statement. Auto-graded.

Reading

2.1.29 Reading: Logical Operators: && || !

Week 5

Learn how to combine conditions with AND, OR, and NOT. Read before the conditionals practice lesson.

Worked Example

2.1.30 Worked Example: Combining conditions

Week 5
Console

2.1.31 Guard with &&

Week 5

Write an if statement whose condition combines two checks with &&. Auto-graded.

Console

2.1.32 Branch with ||

Week 5

Write an if statement whose condition combines two checks with ||. Auto-graded.

Console

2.1.33 Flip It with !

Week 5

Use the ! operator to flip a boolean inside an if condition. Auto-graded.

Worked Example

2.1.34 Worked Example: The OR String-Literal Trap

Week 5
Console

2.1.35 Debug the Door

Week 5

Fix a door-unlock condition that uses || where it should use &&. Auto-graded.

Reading

2.1.36 Reading: Parentheses and Operator Precedence

Week 5

Learn why parentheses make a condition's intent clear even when they aren't strictly required. Read before 2.1.37 Combine &&, ||, and !.

Console

2.1.37 Combine &&, ||, and !

Week 5

Write one if condition that uses all three logical operators together. Auto-graded.

Worked Example

2.1.38 Worked Example: A Condition That Is Always True

Week 5
Console

2.1.39 Predict the Chain

Week 5

Predict the output of an else if chain and a chained ternary before running them. Auto-graded.

Console

2.1.40 Print Settings Advisor

Week 5

Given filament type and layer height, print a recommended print temperature using else if and logical operators. Auto-graded.

Challenge

2.1.41 Challenges: Stretch Problems

Week 5

Stretch problems. Every challenge is required to continue. Auto-graded.

Assignment

2.1.42 Grade Recommendation Advisor

Week 5

Use score, attendance, and lateAssignments to print a grade recommendation. Auto-graded.

Quiz

2.1.43 Conditionals Checkpoint Quiz

Week 5

Five multiple-choice questions on === vs ==, operator precedence, and tracing three conditional snippets. Checked instantly.

→ View full module page
2.2Algorithms and Loops
Slides

2.2.1 Slides: Algorithms and Loops

Unit 2.2 slides: algorithms and loops.

Reading

2.2.2 Reading: What Is an Algorithm?

Week 6

An algorithm is a precise, ordered set of steps to solve a problem. See how that idea turns directly into code.

Reading

2.2.3 Reading: Programs Implement Algorithms

Week 6

An algorithm is the plan. A program is that plan written in a language a computer can run. See the same decision as English, then as JS.

Reading

2.2.4 Reading: Flowchart Shapes

Week 6

Four shapes carry nearly every flowchart. Learn what each one means and the two rules that make a flowchart readable, before you draw one.

Worked Example

2.2.5 Worked Example: Pseudocode → code

Week 6
Console

2.2.6 Plain English to Pseudocode: Largest of Three

Week 6

Turn the largest-of-three algorithm into pseudocode: two checks in a row, each one a question, with the no answer still carrying on to the next step.

Assignment

2.2.7 Write a Decision as Pseudocode

Week 6

Turn a written ticket-price algorithm into numbered pseudocode: get the age, one question with two answers, and print the price. Green here unlocks the 2.2.8 A2.2.1 (Part A) plan.

Assignment

2.2.8 Algorithm in Plain English (Part A)

Week 6

Define algorithm in your own words, then write a precise numbered algorithm for an everyday task. AI-graded.

Reading

2.2.9 Reading: The for Loop

Week 6

Learn the three-part for loop: init, condition, increment. Count to five, then sum a range: the two moves you'll use everywhere.

Worked Example

2.2.10 Worked Example: Tracing a for-loop counter

Week 6
Console

2.2.11 Plain English to Pseudocode: A for-loop That Accumulates

Week 6

Turn the sum-1-to-5 loop into pseudocode: start the total before the loop, add i inside it, and print after it ends.

Console

2.2.12 Count 1 to 10

Week 6

Write a for loop that logs every integer from 1 to 10. Auto-graded.

Reading

2.2.13 Reading: The while Loop

Week 6

A while loop checks its condition before every run. Learn when to choose it over for, and how to avoid an infinite loop.

Worked Example

2.2.14 Worked Example, while vs for + the infinite-loop trap

Week 6
Worked Example

2.2.15 Worked Example: Same Algorithm, Three Spellings

Week 6
Console

2.2.16 Countdown with while

Week 6

Write a while loop that counts down from 10 to 1, logging each value. Auto-graded.

Assignment

2.2.17 For + While Loop Program (Part B)

Week 6

Write a JS program with at least one for loop and one while loop that solves a counting or accumulation problem. Auto-graded.

Console

2.2.18 Fix the Broken Plan

Week 6

A plan arrives with one missing idea: the rider-height check only says what happens when the rider is tall enough. Read the cards, find the gap, and repair it.

Worked Example

2.2.19 Worked Example: Walking Through a Word

Week 6
Console

2.2.20 Count a Letter in a Word

Week 6

Loop through a string and count how many times one letter appears. Auto-graded.

Reading

2.2.21 Reading: Canonical Algorithms & Linear Search

Week 6

A canonical algorithm is a well-known pattern worth knowing by name. Meet linear search: check one item at a time until you find what you're looking for.

Challenge

2.2.22 Challenges: Stretch Problems

Week 6

Stretch problems. Every challenge is required to continue. Auto-graded.

→ View full module page
2.3The Switch Statement
Slides

2.3.1 Slides: The Switch Statement

Unit 2.3 slides: the switch statement.

Reading

2.3.2 Reading: One Value, Many Answers

Week 6

See why a long else-if chain that keeps testing the same variable is a sign JavaScript has a better tool for the job. Read before 2.3.3 Reading: switch Statements.

Reading

2.3.3 Reading: switch Statements

Week 6

Learn how a switch statement picks one case from many without a long if/else chain. Read before 2.3.4 Worked Example: A Menu of Options.

Worked Example

2.3.4 Worked Example: A Menu of Options

Week 6
Worked Example

2.3.5 Worked Example: The Switched Value Is an Expression

Week 6
Console

2.3.6 Plain English to Pseudocode: a switch is a chain of questions

Week 6

Turn plain-English steps into pseudocode for a three-case switch: three questions in a row, a break after each case, and a last line that runs either way.

Console

2.3.7 Build a Switch: Animal Sounds

Week 6

Write a switch that prints the sound an animal makes, with a default for anything else. Auto-graded.

Console

2.3.8 Predict Where default Runs

Week 6

Write two switch statements, predicting the output before you run each one, including one where default is written in the middle. Auto-graded.

Reading

2.3.9 Reading: break and Fall-Through

Week 6

See what JavaScript actually does when a case has no break, and why the bug is easy to miss. Read before 2.3.10 Worked Example: switch vs if-else-if.

Worked Example

2.3.10 Worked Example: switch vs if-else-if

Week 6
Worked Example

2.3.11 Worked Example: A Missing break in the Middle

Week 6
Console

2.3.12 Predict the Fall-Through

Week 6

Write a three-case switch where the first case deliberately has no break, predict the output, then run it and check. Auto-graded.

Console

2.3.13 Fix the Fall-Through Bug

Week 6

This code should print exactly one line but prints two. Find the missing break and fix it. Auto-graded.

Reading

2.3.14 Reading: Grouping Cases

Week 6

Learn how to stack case labels with no code between them so several values share one block. Read before 2.3.15 Worked Example: Weekend or Weekday.

Worked Example

2.3.15 Worked Example: Weekend or Weekday

Week 6
Worked Example

2.3.16 Worked Example: Days in a Month

Week 6
Console

2.3.17 Group Cases: Vowel or Consonant

Week 6

Write a switch with grouped cases that prints Vowel for a, e, i, o, u and Consonant for anything else. Auto-graded.

Reading

2.3.18 Reading: switch Compares Strictly

Week 6

See why a case can silently never match when the switched value is the wrong type. Read before 2.3.19 case false vs case 0: Predict, Then Run.

Console

2.3.19 case false vs case 0: Predict, Then Run

Week 6

Write a switch with case false, case 0, and case '0', then predict which one a number, a boolean, and a string each match. Auto-graded.

Worked Example

2.3.20 Worked Example: Fix 1: Match the Case Type to the Value

Week 6
Worked Example

2.3.21 Worked Example: Fix 2: Convert the Value with Number()

Week 6
Console

2.3.22 Fix the Type Mismatch

Week 6

This code should print Second place and prints No medal instead. Fix it without changing the case values. Auto-graded.

Reading

2.3.23 Reading: Choosing Between if...else and switch

Week 6

Learn the one question that tells you which statement fits a problem. Read before 2.3.24 Worked Example: When switch Fits: Command Dispatch.

Worked Example

2.3.24 Worked Example: When switch Fits: Command Dispatch

Week 6
Worked Example

2.3.25 Worked Example: When switch Doesn't Fit: the Grade Chain

Week 6
Console

2.3.26 Rewrite the Traffic Light as a Switch

Week 6

Rewrite an if/else-if chain that checks a traffic light color as an equivalent switch statement. Auto-graded.

Assignment

2.3.27 switch or if...else? Justify Your Choice

Week 6

Explain which statement fits a given problem and why. AI-graded.

Console

2.3.28 Build a Four-Case Switch: Drink Sizes

Week 6

Write a switch with at least four cases and a default that prices a drink by size. Auto-graded.

Console

2.3.29 Convert an if-chain to switch

Week 6

Rewrite an if/else-if chain as a switch statement with at least two cases, a default, and break. Auto-graded.

Assignment

2.3.30 Print Settings Advisor

Week 6

Write a switch on filamentType with at least four cases and a default, printing a recommended temperature and speed for each. Auto-graded.

Challenge

2.3.31 Challenges: Stretch Problems

Week 6

Stretch problems. Every challenge is required to continue. Auto-graded.

→ View full module page
2.4Loop Control and Nested Loops
Slides

2.4.1 Slides: Loop Control and Nested Loops

Unit 2.4 slides: loop control and nested loops.

Reading

2.4.2 Reading, for vs while: Choosing a Loop

Week 6

for and while can do the same job. Learn the test that tells you which one to reach for. Read before Predict: Which Loop Fits?

Worked Example

2.4.3 Worked Example: Predict: Which Loop Fits?

Week 6
Console

2.4.4 Write Both: Known Count, Unknown Count

Week 6

Write a for loop for a known-count task and a while loop for an unknown-count task. Auto-graded.

Reading

2.4.5 Reading: The do...while Loop

Week 6

while and do...while test their condition at different ends, and that changes whether the body ever runs at all. Read before Predict: while vs do...while.

Worked Example

2.4.6 Worked Example, while vs do...while: The Difference in One Line

Week 6
Console

2.4.7 Plain English to Pseudocode: do...while

Week 6

Turn plain-English steps into pseudocode for a do...while loop: the body runs first, and the question comes after it.

Console

2.4.8 do...while: Count 1 to 5

Week 6

Write a do...while loop that prints 1 through 5, then a second one whose condition starts false and still runs once. Auto-graded.

Reading

2.4.9 Reading: Leaving Early with break

Week 6

break ends a loop the moment you tell it to, even if the loop's own condition never becomes false. Read before Searching Without a Known End.

Worked Example

2.4.10 Worked Example: Searching Without a Known End

Week 6
Console

2.4.11 Plain English to Pseudocode: Search Until Found

Week 6

Turn plain-English steps into pseudocode for a search that has no limit of its own: the question inside the loop is the only way out, and the early exit is its own step.

Console

2.4.12 Break When the Square Passes 50

Week 6

Count up from 1 and break as soon as the square of the count exceeds 50. Auto-graded.

Reading

2.4.13 Reading: Skipping a Round with continue

Week 6

continue is gentler than break: it skips only the current round and keeps the loop running. Read before Filtering While You Loop.

Worked Example

2.4.14 Worked Example: Filtering While You Loop

Week 6
Console

2.4.15 Plain English to Pseudocode: continue Skips, Doesn't Leave

Week 6

Turn plain-English steps into pseudocode for a loop that skips the even numbers: continue ends one round early but stays in the loop.

Reading

2.4.16 Reading: The continue Trap in a while Loop

Week 6

In a for loop, continue still runs the increment. In a while loop it can jump straight past your update line, and hang the program. Read before The continue Trap, and Its Fix.

Worked Example

2.4.17 Worked Example: The continue Trap, and Its Fix

Week 6
Worked Example

2.4.18 Worked Example: Predict: break vs continue

Week 6
Console

2.4.19 Multiples of 3 with continue

Week 6

Loop over 1 to 20 and print only the multiples of 3, using continue to skip the rest. Auto-graded.

Reading

2.4.20 Reading: Infinite Loops: Three Causes

Week 6

An infinite loop never crashes and never errors: it just never finishes. Learn the three usual reasons before you have to debug one. Read before Making an Infinite Loop Safe.

Worked Example

2.4.21 Worked Example: Making an Infinite Loop Safe

Week 6
Console

2.4.22 Fix the Infinite Loop

Week 6

A countdown plan arrives whose loop never says when it stops. Find the missing way out and add it, so the plan can finally reach its end.

Assignment

2.4.23 Debug Five Loops

Week 6

Five loop programs are broken: two never stop, two are off by one, one has a do...while logic error. Fix all five and explain each bug in a comment. Auto-graded.

Reading

2.4.24 Reading: Nested Loops

Week 7

A loop inside a loop is a nested loop, and the inner one runs all the way through for every single round of the outer one. Read before A Multiplication Table.

Worked Example

2.4.25 Worked Example: A Multiplication Table

Week 7
Console

2.4.26 Plain English to Pseudocode: Nested Loops

Week 7

Turn plain-English steps into pseudocode for a row/col nested loop: the inner loop starts over for every round of the outer loop.

Worked Example

2.4.27 Worked Example: break Leaves Only the Inner Loop

Week 7
Worked Example

2.4.28 Worked Example: Breaking Out of Both Loops

Week 7
Reading

2.4.29 Reading: Nested Loops Get Expensive

Week 7

Two nested loops over 1,000 items each is a million rounds. Learn to count the cost before you look anywhere else for a slowdown. Read before Triangle of Stars.

Console

2.4.30 Triangle of Stars

Week 7

Use a nested loop to print a triangle of stars, one row at a time, where the inner loop's limit depends on the outer loop's counter. Auto-graded.

Console

2.4.31 Fix the Duplicate Pairs

Week 7

A nested loop is supposed to print each pair once but prints every pair twice, including pairs of a number with itself. Fix the inner loop's starting value. Auto-graded.

Assignment

2.4.32 Print a Grid Pattern

Week 7

Write a nested-loop program that prints a grid of at least 5x5, with the dimensions controlled by variables, not hardcoded loop bounds. Auto-graded.

Challenge

2.4.33 Challenges: Stretch Problems

Week 7

Stretch problems. Every challenge is required to continue. Auto-graded.

→ View full module page
2.5Handling Errors with try/catch
Slides

2.5.1 Slides: Handling Errors with try/catch

Unit 2.5 slides: handling errors with try/catch.

Reading

2.5.2 Reading: What an Error Actually Does

Week 7

See what a runtime error does to a running program, and tell it apart from a syntax error. Read before 2.5.3 Runtime or Syntax?.

Console

2.5.3 Runtime or Syntax?

Week 7

Write code that fails at runtime, not at parse time, and confirm which lines still run. Auto-graded.

Reading

2.5.4 Reading: try...catch: Attempt and Recover

Week 7

Learn how try...catch lets a program recover from a runtime error instead of stopping cold. Read before 2.5.5 Worked Example, Only Wrap What Can Fail.

Worked Example

2.5.5 Worked Example, Only Wrap What Can Fail

Week 7
Console

2.5.6 Wrap Only What Can Fail

Week 7

Rewrite a try that wraps too much so the total still prints even when the risky line fails. Auto-graded.

Console

2.5.7 Plain English to Pseudocode: try/catch

Week 7

Turn plain-English steps into pseudocode for try/catch: attempt a risky step, run the catch only if it fails, then carry on either way.

Console

2.5.8 Catch Your First Error

Week 7

Write a try...catch that falls back gracefully when a variable doesn't exist, and confirm the program still finishes. Auto-graded.

Console

2.5.9 What Runs, What Doesn't

Week 7

Build a try...catch and predict exactly which of four lines print. Auto-graded.

Reading

2.5.10 Reading: The Empty catch Trap

Week 7

See why a catch block that does nothing is worse than no try...catch at all. Read before 2.5.11 Fix the Silent Catch.

Console

2.5.11 Fix the Silent Catch

Week 7

An empty catch block is hiding a failure. Add a report so the next person can see it. Auto-graded.

Reading

2.5.12 Reading: Reading the Error Object

Week 7

Read err.name and err.message to say exactly what went wrong. Read before 2.5.13 Worked Example: Reporting Instead of Guessing.

Worked Example

2.5.13 Worked Example: Reporting Instead of Guessing

Week 7
Console

2.5.14 Report the Error

Week 7

Cause a TypeError on purpose and print both err.name and err.message. Auto-graded.

Reading

2.5.15 Reading: Throwing Your Own Errors

Week 7

Raise your own error with throw when a value breaks the program's rules, not the language's. Read before 2.5.16 Worked Example: Validate, Then Trust.

Worked Example

2.5.16 Worked Example: Validate, Then Trust

Week 7
Console

2.5.17 Plain English to Pseudocode: Validate Before You Trust

Week 7

Turn plain-English steps into pseudocode for two validation checks in a row, each one throwing when the input is bad, with the real work only after both pass.

Reading

2.5.18 Reading: throw vs if: The Distance Rule

Week 7

Decide when a problem deserves a throw and when a plain if is simpler. Read before 2.5.19 Reject the Bad Input.

Console

2.5.19 Reject the Bad Input

Week 7

Throw an error when a password is too short, and catch it with a clear message. Auto-graded.

Console

2.5.20 What Happens After a throw?

Week 7

Build a try block where a throw sits between two other lines, and confirm exactly which lines run. Auto-graded.

Reading

2.5.21 Reading: Cleaning Up with finally

Week 7

Run cleanup code whether try succeeded or failed. Read before 2.5.22 When Does finally Run?.

Console

2.5.22 When Does finally Run?

Week 7

Build a try/catch/finally and confirm finally runs in both the success and the failure case. Auto-graded.

Reading

2.5.23 Reading: What try...catch Cannot Do

Week 7

Two limits worth knowing: try...catch can't save a syntax error, and it only guards code that runs inside it. Read before 2.5.24 Guard Only What's Inside.

Console

2.5.24 Guard Only What's Inside

Week 7

Write two risky lines: one guarded by try...catch, one left outside it, and see which one crashes. Auto-graded.

Console

2.5.25 Predict, Then Run: try/catch/finally Together

Week 7

Predict the output of a try/catch/finally with a throw inside it, then build it and check. Auto-graded.

Assignment

2.5.26 Loop with try/catch

Week 7

Loop over three raw readings and use try/catch to reject bad input with a friendly message instead of crashing. Auto-graded.

Challenge

2.5.27 Challenges: Stretch Problems

Week 7

Stretch problems. Every challenge is required to continue. Auto-graded.

→ View full module page
2.6Chapter 2 Group Performance Assessment
2.7Chapter 2 Individual Performance Assessment
Chapter 3Functions and Data
3.1Functions: Definition and Calls
Slides

3.1.1 Slides: Functions

Unit 3.1 slides: calling a function, defining one, hoisting, and why functions make programs shorter and easier to change.

Reading

3.1.2 Reading: Defining & Calling a Function

Week 7

Understand how to define a function with function name() {} and call it. Defining a function is not the same as running it.

Quiz

3.1.3 Quiz: Identify the Function Calls

Week 7

Spot which lines are function calls and count how many run. Checked instantly.

Worked Example

3.1.4 Worked Example: Defining, Calling, and Hoisting

Week 7

Trace what JavaScript actually does when it reads a function definition versus when it runs a call — and why a call written above its definition still works.

Assignment

3.1.5 Lab: Fix the Syntax and the Name

Week 7

Take a broken function header — missing parentheses, wrong-case name — and fix both problems. Auto-graded.

Reading

3.1.6 Reading: Why Bother?

Week 7

Three reasons to write functions at all: modularity, reusability, maintainability.

Worked Example

3.1.7 Worked Example: Refactoring calcDistance

Week 7

Watch the same three distance calculations shrink from nine lines to three once the math moves into one function.

Assignment

3.1.8 Lab: Concessions Stand

Week 7

Write a parameterless function, concessions(), that prints the food and drink options at a cinema, then call it. Auto-graded.

Assignment

3.1.9 Lab: Terms and Conditions Loop

Week 7

Write terms(), a parameterless function that asks the user to accept terms and conditions, then call it once per user in a loop. Auto-graded.

Assignment

3.1.10 Lab: Refactor the Receipt Header

Week 7

The starter prints a repeated header three times. Rewrite it so the header lives in one function, called three times, with the output unchanged. Auto-graded.

Reading

3.1.11 Reading: The Function-Call Shape

A new shape arrives: the double-rail rectangle stands for a whole sequence defined somewhere else, and flow comes back from it.

Assignment

3.1.12 Plan Before You Refactor

Plan the grade-advisor refactor in pseudocode before you touch the code: name the two functions, say what each one does, and write the main program as calls to them. The gate for 3.1.13: plan first, refactor second.

Assignment

3.1.13 Lab: Refactor the Grade Advisor

Week 7

Take your grade-advisor program from 2.1.42 and break it into two named, parameterless functions: decideGrade() and printAdvice(). Auto-graded.

Assignment

3.1.14 Write Up What You Built

Week 7

Write the grade-advisor program you just refactored as pseudocode: set up the three values, call decideGrade(), call printAdvice(), and notice the main program has no decision left in it.

Quiz

3.1.15 Functions: Definition and Calls

Week 7

Eight multiple-choice questions on identifying calls, defining functions, hoisting, naming, and benefits. Checked instantly.

→ View full module page
3.2Parameters and Return Values
Slides

3.2.1 Slides: Parameters and Return Values

Week 7

Unit 3.2 slides: parameters and arguments, return values, print versus return, composing functions, and scope. Shown from a copy of the bookSHelf deck kept in this site.

Reading

3.2.2 Reading: Parameters

Week 7

Parameters let you pass inputs into a function, so the same function can give a different result each time you call it.

Reading

3.2.3 Reading: Passing Information In

Week 7

A function with a parameter leaves a blank for the caller to fill, so one definition can produce a different result every time you call it.

Worked Example

3.2.4 Worked Example: a function with one parameter

Week 7
Reading

3.2.5 Reading: Parameters and Arguments

Week 7

These two words are used interchangeably in conversation but mean different things precisely: a parameter lives in the definition, an argument is passed at the call.

Assignment

3.2.6 Lab: shout(word)

Week 7

Write a one-parameter function, shout, that prints its word in capital letters, then call it with two different words. Practice, not graded: the checks call your function.

Reading

3.2.7 Reading: Order Matters

Week 7

A function matches arguments to parameters by position, not by name, so swapping two arguments changes the answer without raising an error.

Assignment

3.2.8 Lab: greet with a Default Name

Week 7

Write greet(name) so that calling it with no argument greets "friend", using a default parameter, and calling it with a name greets that name. Practice, not graded: the checks call your function.

Assignment

3.2.9 Lab: findRectangleArea (multi-parameter)

Week 7

Define findRectangleArea(width, height) that works out the area and prints it, then call it twice. Auto-graded.

Console

3.2.10 Plain English to Pseudocode: Tracing Parameter Values

Week 7

Turn plain-English steps into pseudocode for a program that passes base into showPriceWithTax(price), then decides Over budget or Within budget from the same base.

Reading

3.2.11 Reading: Getting a Value Back with `return`

Week 7

return ends a function and hands a value back to the caller, so the call becomes an expression you can store, print, or use in arithmetic.

Worked Example

3.2.12 Worked Example: return instead of print

Week 7
Assignment

3.2.13 Lab: square(n)

Week 7

Write square(n) so that it hands back n times n with return, and use the value it gives back. The first return practice. Practice, not graded: the checks call your function.

Reading

3.2.14 Reading: `return` Ends the Function

Week 7

return does two jobs at once: it hands back a value and stops the function right there, so anything after it does not run.

Assignment

3.2.15 Lab: an Early-Return Guard Clause

Week 7

Write a function whose first check returns early when the input is invalid, so the valid path runs without an else. Auto-graded.

Reading

3.2.16 Reading: Printing Is Not Returning

Week 7

console.log shows a value to a human; return gives it to the program. A function that prints produces undefined, which is why its result is unusable.

Worked Example

3.2.17 Worked Example: Which Should a Function Do?

Week 7
Assignment

3.2.18 Lab: Fix a Function That Prints Instead of Returning

Week 7

A function computes correctly but prints its result, so the caller gets undefined. Fix it to return, and prove the fix with arithmetic. Auto-graded.

Assignment

3.2.19 Lab: initials(first, last)

Week 7

Write initials(first, last) so that it returns the first letter of each name joined into one string, using first[0]. Practice, not graded: the checks call your function.

Reading

3.2.20 Reading: Building With Returned Values

Week 7

Because a call to a returning function is itself a value, calls can be fed straight into other calls, which is how small functions build up to big programs.

Worked Example

3.2.21 Worked Example: Chaining Two Functions

Week 7
Console

3.2.22 Plain English to Pseudocode: Data Flow Through Chained Calls

Week 7

Turn five plain-English steps into pseudocode for two nested calls: double(5) first, addTen on what it hands back, then a Big/Small decision on the result.

Assignment

3.2.23 Lab: Compose Two Functions

Week 7

Write two returning functions, triple and addSeven, then feed one result into the other in both orders and log the chains. Auto-graded.

Reading

3.2.24 Reading: Scope: Local vs Global

Week 7

A variable declared inside a function is local: it only exists while that function runs and is invisible outside it. Global variables are accessible everywhere.

Assignment

3.2.25 Lab: Scope Prediction Exercise

Week 7

Write a global and a local variable, then try to read the local one outside its function and watch the ReferenceError. Auto-graded.

Assignment

3.2.26 Lab: findMax & isEven

Week 7

Define two functions, findMax(a, b) and isEven(n), that take parameters and return a value. Auto-graded.

Assignment

3.2.27 Lab: largest(a, b, c)

Week 7

Write largest(a, b, c) so that it returns the biggest of three numbers, whatever order they come in. Practice, not graded: the checks call your function.

Assignment

3.2.28 Lab: Sum 1 to N

Week 7

Define sumToN(n) that uses a for loop to add every integer from 1 to n and returns the total. Auto-graded.

Quiz

3.2.29 Parameters and Return Values

Week 7

Ten multiple-choice questions on parameters, arguments, return, scope, early return, and why printing is not returning. Checked instantly.

→ View full module page
3.3Arrays
Slides

3.3.1 Slides: Arrays

Week 8

Unit 3.3 slides: arrays, indexes, push and pop, looping over an array, and nested arrays. Shown from a copy of the bookSHelf deck kept in this site.

Reading

3.3.2 Reading: Array Basics: Index, push, pop

Week 8

Learn how arrays store ordered lists, how zero-based indexing works, and how push, pop, and length let you grow and shrink the list. Read before the array exercises.

Reading

3.3.3 Reading: Changing an Item by Index

Week 8

Learn how assigning to arr[i] replaces one item without changing the array's length. Read before the index-assignment lab.

Assignment

3.3.4 Lab: Update Scores by Index

Week 8

Reassign values inside an array by their index to update scores in place. Auto-graded: the code runs and the final scores are checked.

Reading

3.3.5 Reading: Looping Over Arrays (for / for…of)

Week 8

Learn two ways to visit every item in an array: a plain for loop using the index, and the cleaner for...of loop. Read before the array iteration exercises.

Assignment

3.3.6 Lab: Fix the Off-by-One Loop

Week 8

A loop that should print every price also prints an extra undefined. Find the part of the loop that lets it run one round too long and fix it. Practice, not graded: the checks call your function.

Reading

3.3.7 Reading: Adding and Removing from the Front

Week 8

Learn .unshift() and .shift(), the front-of-list partners to .push() and .pop() you already know. Read before the queue lab.

Assignment

3.3.8 Lab: Front-of-Line Queue

Week 8

Use push and shift to move people through a queue, first in first out. Auto-graded: the code runs and the final line and the person served are checked.

Assignment

3.3.9 Lab: rotate(items)

Week 8

Write rotate(items): the first item goes to the back of the array and the function returns the array. Practice with shift and push, not graded: the checks call your function.

Reading

3.3.10 Reading: Splitting Text into Lines (.split)

Week 8

Learn how .split() turns one big string into an array of lines: the usual first step when text arrives as one long string. Read before the exercises that process lines of text.

Assignment

3.3.11 Lab: countWords(text)

Week 8

Write countWords(text): split a sentence at its spaces and return how many words there are. Practice with split and length, not graded: the checks call your function.

Assignment

3.3.12 Sum an Array

Week 8

Use a for loop to add up all numbers in an array, then log the total. Auto-graded: the code runs and the total is checked.

Worked Example

3.3.13 Worked Example: A tiny menu loop

Week 8
Console

3.3.14 Plain English to Pseudocode: Looping Over an Array

Week 8

Turn plain-English steps into pseudocode for a loop over an array with a check inside it: start the counter, look at each price, add one when it is under 10, and print once at the end.

Reading

3.3.15 Reading: Arrays and Functions

Week 8

Learn how a whole array can be one function parameter, and how a function can build and return a new array. Read before the filter-function lab.

Assignment

3.3.16 Lab: lastItem(items)

Week 8

Write lastItem(items): read the last item of an array parameter and return it, leaving the array exactly as it was. Practice, not graded: the checks call your function.

Worked Example

3.3.17 Worked Example: Keeping Only the Passing Scores

Week 8
Assignment

3.3.18 Lab: smallest(numbers)

Week 8

Write smallest(numbers): find the smallest number in an array, starting your running answer from the array's own first item. Practice, not graded: the checks call your function.

Assignment

3.3.19 Lab: Write a Function That Returns a New Array

Week 8

Write a function that builds and returns a new array of transformed values (for example, each number doubled with result.push(n * 2), as in 3.3.15), proving the original is untouched. Auto-graded.

Reading

3.3.20 Reading: Lists Inside Lists

Week 8

Learn how an array can hold other arrays, which is how you store a grid or a table of rows. Read before the nested-array lab.

Worked Example

3.3.21 Worked Example: A Tic-Tac-Toe Board as a Nested Array

Week 8
Assignment

3.3.22 Lab: Read and Update a Nested Array

Week 8

Read and reassign values in a nested array with double-index syntax, then sum every cell with a nested loop. Auto-graded: the code runs and the final grid and total are checked.

Quiz

3.3.23 Arrays Checkpoint

Week 8

Eight multiple-choice questions on arrays: changing items by index, loops and the off-by-one, push, pop, shift and unshift, split, arrays and functions, and nested arrays. Checked instantly.

Assignment

3.3.24 Arrays

Week 8

Work with lists of values: create, add, remove, and iterate.

→ View full module page
3.4Function Expressions and Arrow Functions
Slides

3.4.1 Slides: Function Expressions and Arrow Functions

Unit 3.4 slides: functions as values, function expressions, arrow functions and their shorthand rules, callbacks, and hoisting.

Reading

3.4.2 Reading: A Function Is a Value

Week 8

A function can be stored in a variable, copied, and passed around like a number or a string. Read before the function-expression exercises.

Worked Example

3.4.3 Worked Example: Storing a Function in a Variable

Week 8
Reading

3.4.4 Reading: Function Expressions

Week 8

When a function is a value, you can write it directly on the right of an equals sign. Meet the function expression and how it differs from a declaration.

Assignment

3.4.5 Lab: Rewrite a Declaration as an Expression

Week 8

Take a named function declaration and rewrite it as a function expression assigned to a const, then call it. Auto-graded.

Reading

3.4.6 Reading: Arrow Functions

Week 8

Arrow functions are a shorter way to write a function expression. Learn the (parameters) => result shape and see one function in all three forms.

Worked Example

3.4.7 Worked Example: The Same Function Three Ways

Week 8
Reading

3.4.8 Reading: The Shorthand Rules

Week 8

The four optional shortenings of an arrow function, including the implicit return and the classic braces mistake that produces undefined.

Console

3.4.9 Plain English to Pseudocode: A Function That Calls Its Parameter Twice

Week 8

Turn four plain-English steps into pseudocode for applyTwice: read the operation and the value, make the first call, make the second call on its result, and print.

Assignment

3.4.10 Lab: Implicit-Return Rewrite Drill

Week 8

Write three one-line arrow functions using implicit return, and call each one. Auto-graded.

Reading

3.4.11 Reading: Passing a Function to a Function

Week 8

Because a function is a value, it can be an argument. Learn what a callback is and why passing one separates the loop from the rule.

Worked Example

3.4.12 Worked Example: An Arrow Passed as a Callback

Week 8
Assignment

3.4.13 Lab: Write a One-Line Arrow Callback

Week 8

Write a helper that takes a callback, then pass it a one-line arrow. Auto-graded.

Reading

3.4.14 Reading: Declaration or Expression?

Week 8

A declaration is hoisted and can be called from above its line; an expression or arrow cannot. Learn the one real difference and when to choose each.

Console

3.4.15 Plain English to Pseudocode: Decision Tree for Form Choice

Week 8

Turn the rule for choosing a function form into pseudocode: is it a main operation called from several places, and if not, is its body a single expression?

Assignment

3.4.16 Lab: Rewrite 3 Named Functions as Arrows

Week 8

Convert three function declarations into one-line arrow expressions and confirm each still behaves the same. Auto-graded.

Assignment

3.4.17 Lab: Fix a Broken Arrow

Week 8

A two-parameter arrow function was written without the parentheses around its parameters, so the line will not parse. Fix it. Auto-graded.

Worked Example

3.4.18 Worked Example: An Arrow With No Parameters

Week 8
Assignment

3.4.19 Lab: Callback Capstone

Week 8

Write a counting helper that takes a callback, then use it with a one-line arrow to count matching values in an array. Auto-graded.

Console

3.4.20 Plain English to Pseudocode: Full Syntax-Forms Comparison

Week 8

Turn one operation, adding two numbers, into pseudocode that walks through all three function forms: is it named, is it written with =>, and one print that shows all three results.

Assignment

3.4.21 Lab: Parameters, Return Values, and Arrow Syntax

Week 8

Write a function with a parameter and a return value, a second function of your own, and an arrow function, then call them and print the results. Auto-graded.

Quiz

3.4.22 Function Expressions and Arrow Functions

Week 8

Eight multiple-choice questions on function values, expressions, arrow shorthand, callbacks, and hoisting. Checked instantly.

→ View full module page
3.5Objects and Properties
Slides

3.5.1 Slides: Objects and Properties

Week 8

Unit 3.5 slides: objects and properties, dot versus bracket access, nested objects, arrays of objects, methods, and destructuring.

Reading

3.5.2 Reading: Grouping Related Values

Week 8

Why an object exists: several facts about one thing, grouped under a single name with key: value pairs.

Worked Example

3.5.3 Worked Example: An Object Literal for One Record

Week 8
Reading

3.5.4 Reading: Reading and Changing Properties

Week 8

Read a property with a dot, change or add one by assignment, remove one with delete, and know why a missing property is undefined, not an error.

Assignment

3.5.5 Lab: Read and Update Object Fields

Week 8

Build one object, read a field with a dot, change a field, add a new field, and print the object. Auto-graded.

Reading

3.5.6 Reading: Square Brackets and Computed Keys

Week 8

When dot notation cannot work: keys with spaces, and keys held in a variable. Square brackets evaluate the name first.

Worked Example

3.5.7 Worked Example: Bracket Access With a Variable Key

Week 8
Assignment

3.5.8 Lab: Dot vs. Bracket — When You're Forced to Bracket

Week 8

Read a key with a space and a key held in a variable, and print every key/value pair with Object.keys. Auto-graded.

Reading

3.5.9 Reading: Objects Inside Objects and Arrays

Week 8

A property's value can be another object or an array. Read a nested chain left to right, and see the array-of-objects shape.

Worked Example

3.5.10 Worked Example: A Nested Object Access Chain

Week 8
Console

3.5.11 Plain English to Pseudocode: Tracing a Nested Access

Week 8

Turn a loop that reads a nested price from each item into pseudocode, then read the customer's name and ask the VIP question once, after the loop.

Assignment

3.5.12 Lab: Build a Small Nested-Object Structure

Week 8

Build an object with a nested object and an array of objects, then read values out of it. Auto-graded.

Reading

3.5.13 Reading: Methods

Week 8

A method is a property whose value is a function, called with parentheses. See why word.toUpperCase needs () but word.length does not.

Worked Example

3.5.14 Worked Example: An Object With a Method

Week 8
Assignment

3.5.15 Lab: Add a Method to an Object

Week 8

Give an object a method, call it, and print its return value. Auto-graded.

Reading

3.5.16 Reading: Objects as Named Arguments

Week 8

Pass one options object instead of several positional arguments, so every value carries its name to the call site and order cannot swap it.

Worked Example

3.5.17 Worked Example: A Function Taking One Options Object

Week 8
Assignment

3.5.18 Lab: Rewrite a Multi-Parameter Function to Take an Object

Week 8

Take a function with three positional parameters and rewrite it to read one options object instead. Auto-graded.

Reading

3.5.19 Reading: Destructuring

Week 8

Unpack properties into variables in one statement. Objects match by name, arrays match by position.

Worked Example

3.5.20 Worked Example: Destructuring in a Parameter List

Week 8
Console

3.5.21 Plain English to Pseudocode: Destructuring vs. Plain Access

Week 8

Turn four plain-English steps into pseudocode for describeBox(): unpack width, height and color from options in one step, build the note, add "(wide)" only when width is greater than height, then give the note back.

Assignment

3.5.22 Lab: Destructure 3 Fields From an Object

Week 8

Unpack three fields in one statement, use the bare names, and rewrite a function to destructure its parameter. Auto-graded.

Worked Example

3.5.23 Worked Example: A Record-Shaped Object

Week 8
Assignment

3.5.24 Lab: Parallel-Arrays-vs-Object Refactor

Week 8

Refactor three parallel arrays into one array of records, then read the fields back with a dot. Auto-graded.

Assignment

3.5.25 Lab: Objects Capstone — Build, Read, Destructure

Week 8

Build an array of records, read fields with dots and brackets, and destructure a record into variables. Auto-graded.

Quiz

3.5.26 Objects and Properties

Week 8

Eight multiple-choice questions on object literals, dot vs bracket access, nesting, methods, and options objects. Checked instantly.

→ View full module page
3.6Functions: Pass by Value/Reference
Slides

3.6.1 Slides: Pass by Value/Reference

Week 7

Unit 3.6 slides: what a function receives, mutating versus reassigning, side effects, and working on a copy.

Reading

3.6.2 Reading: Pass by Value vs Reference

Week 7

Primitives (numbers, strings, booleans) are copied when passed to a function: the original is safe. Objects and arrays are shared: a function can change the original.

Worked Example

3.6.3 Worked Example: Mutating an Array Parameter

Week 7
Assignment

3.6.4 Lab: Predict Output — Primitive vs. Array Argument

Week 7

Write one function that reassigns a number parameter and one that mutates an array parameter, then log the caller's variables to prove which change escaped. Auto-graded.

Reading

3.6.5 Reading: Changing vs. Reassigning

Week 7

Mutating an object changes what it holds; reassigning a name points it somewhere else. Only one of those reaches the caller.

Worked Example

3.6.6 Worked Example: Reassigning a Parameter Doesn't Escape

Week 7
Console

3.6.7 Plain English to Pseudocode: Reassignment vs. Mutation Trace

Week 7

Turn plain-English steps into pseudocode for process(nums): one write mutates the shared array and the caller sees it, the other reassigns the local name and the caller does not.

Assignment

3.6.8 Lab: Fix a Function That Reassigns Instead of Mutating

Week 7

A function is supposed to update the caller's array but reassigns its parameter instead, so nothing changes. Fix the body so the update reaches the caller. Auto-graded.

Reading

3.6.9 Reading: Side Effects and Copies

Week 7

A side effect is a change that outlives the call. Make it the whole job or work on a copy so the caller's data survives.

Reading

3.6.10 Reading: Defensive Copying: [...] and {...}

Week 7

Protect the original by copying before you change: spread [...arr] makes a new array so mutations stay in your copy.

Worked Example

3.6.11 Worked Example: Defensive Copy Before Mutating

Week 7
Assignment

3.6.12 Lab: Object-Parameter Mutation

Week 7

Mutate a property on an object parameter and prove the caller sees it, then write a non-mutating version that keeps the original untouched. Auto-graded.

Assignment

3.6.13 Lab: Nested-Structure Mutation

Week 7

Show that a spread copy is only one level deep: change a nested array inside the copy and the original still changes. Then fix it with a deep copy. Auto-graded.

Worked Example

3.6.14 Worked Example: Why a Function Copies Before It Loops

Week 7
Assignment

3.6.15 Writeup: Pass by Value vs Reference

Week 7

Explain pass by value and pass by reference in your own words, give one example of each, and describe a bug that could happen if you forget the difference.

Assignment

3.6.16 Lab: Pass-by-Reference Capstone Practice

Week 7

Build a small scorebook that adds scores without harming the caller's array, and a function that updates an object's property the caller can see. Auto-graded.

Quiz

3.6.17 Pass by Value/Reference

Week 7

Eight multiple-choice questions on primitives vs objects, mutation vs reassignment, side effects, and defensive copying. Checked instantly.

→ View full module page
3.7Array Methods
Slides

3.7.1 Slides: Array Methods

Week 9

Unit 3.7 slides: map, slice, concat, the spread operator, and copying an object with changes.

Reading

3.7.2 Reading: Transforming a List with `.map()`

Week 9

Learn how .map() builds a new array by calling your callback once per element, and why the original list is never changed. Read before the .map() lab.

Worked Example

3.7.3 Worked Example: `.map()` Over a Numeric Array

Week 9
Assignment

3.7.4 Lab: Transform a List Without Mutating the Input

Week 9

Use .map() to build a transformed copy of an array, then demonstrate the original is unchanged. Auto-graded.

Console

3.7.5 Plain English to Pseudocode: What `.map()` Does for You

Week 9

Turn four plain-English steps into pseudocode for what .map() does: a loop you did not write, one result per item, collected in a new list.

Reading

3.7.6 Reading: Taking Part of a List with `.slice()`

Week 9

Learn how .slice(start, end) copies part of an array, why the end index is excluded, and why the original is never changed. Read before the .slice() lab.

Worked Example

3.7.7 Worked Example: `.slice()` Copies a Range

Week 9
Assignment

3.7.8 Lab: Extract a Sub-List with `.slice()`

Week 9

Create an array, copy a middle range and a run to the end with .slice(), then show the original is unchanged. Auto-graded.

Reading

3.7.9 Reading: Joining Lists with `.concat()`

Week 9

Learn how .concat() returns a new array with another array's items added on the end, leaving both originals untouched. Read before the .concat() lab.

Worked Example

3.7.10 Worked Example: `.concat()` Without Mutating Either Input

Week 9
Assignment

3.7.11 Lab: `.concat()` Two Lists

Week 9

Join two arrays into a new one with .concat(), then show both originals are unchanged. Auto-graded.

Reading

3.7.12 Reading: Spreading an Array into Arguments

Week 9

Learn how the spread operator ... unpacks an array into separate arguments, and how the same three dots mean the opposite in a function definition. Read before the spread-call example.

Worked Example

3.7.13 Worked Example: `fn(...arr)` Spread-Call

Week 9
Reading

3.7.14 Reading: Spreading into a New Array or Object

Week 9

Learn how spread copies contents into a new array or object literal, and how { ...obj, field } makes a copy with one value changed. Read before the spread labs.

Worked Example

3.7.15 Worked Example: Copying an Object with Changes

Week 9
Console

3.7.16 Plain English to Pseudocode: Spread vs. Rest, Side by Side

Week 9

Turn four plain-English steps into pseudocode for the body of total(...numbers): the same gathering loop whether the caller spreads an array or lists the numbers.

Assignment

3.7.17 Lab: Build a New Array with Spread

Week 9

Use spread to combine two arrays and to add loose values around a copied one, without changing any input. Auto-graded.

Assignment

3.7.18 Lab: Build a New Object with Spread + Override

Week 9

Use object spread to copy an object with one property overridden and one property added, leaving the original untouched. Auto-graded.

Reading

3.7.19 Reading: What Else Is Out There

Week 9

Meet the array methods this book does not teach but other people's code uses: filter, forEach, reduce, indexOf, includes, sort, reverse, and every. Read to recognize them.

Worked Example

3.7.20 Worked Example: Chaining `.map()` off a `.push()`-Built Array

Week 9
Assignment

3.7.21 Lab: Mutating vs. Non-Mutating Methods Drill

Week 9

Demonstrate one method that changes its array and one that returns a new array, logging before and after each. Auto-graded.

Assignment

3.7.22 Lab: Array-Methods Capstone

Week 9

Combine the module's non-mutating tools: build a list, transform it with .map(), take a range with .slice(), join with .concat() or spread, and copy an object with an override. Auto-graded.

Quiz

3.7.23 Array Methods

Week 9

Eight multiple-choice questions on .map(), .slice(), .concat(), spread, rest, and mutating versus non-mutating methods. Checked instantly.

→ View full module page
3.8Saving and Loading Data
Slides

3.8.1 Slides: Saving and Loading Data

Week 10

Unit 3.8 slides: JSON, JSON.stringify and JSON.parse, parsing that can fail, and saving by key in storage.

Reading

3.8.2 Reading: Data Has to Outlive the Program

Week 10

See why a value that only lives in memory is gone the moment the tab closes, and why everything that stores data stores text. Read before the stringify reading.

Worked Example

3.8.3 Worked Example: Readable Output vs. What Doesn't Survive

Week 10
Reading

3.8.4 Reading: `JSON.stringify` — Object to Text

Week 10

Learn how JSON.stringify turns an object or array into a single string with every property intact, and what changes from a JavaScript literal. Read before the stringify lab.

Reading

3.8.5 Reading: Readable Output

Week 10

See how the second and third arguments to JSON.stringify turn compact text into indented, human-readable output, and when to use each form.

Reading

3.8.6 Reading: What Does Not Survive

Week 10

Learn what JSON silently drops — functions and undefined values — and why that is JSON storing data rather than behaviour, not a bug.

Assignment

3.8.7 Lab: Stringify an Object and Spot What Got Dropped

Week 10

Build an object that has a method and an undefined property, stringify it, and find out in the output what JSON refused to carry. Auto-graded.

Reading

3.8.8 Reading: `JSON.parse` — Text Back to Object

Week 10

Learn how JSON.parse turns a JSON string back into a real value whose numbers add and whose arrays have a length. Read before the round-trip labs.

Worked Example

3.8.9 Worked Example: A Round Trip

Week 10
Assignment

3.8.10 Lab: Round-Trip an Object Through JSON

Week 10

Save an object to JSON text, restore it with JSON.parse, and prove the restored copy is independent of the original. Auto-graded.

Assignment

3.8.11 Lab: Round-Trip an Array of Objects

Week 10

Round-trip a game-state shape — an object holding an array of item objects — through stringify and parse, then read a nested field back. Auto-graded.

Reading

3.8.12 Reading: Parsing Can Fail

Week 10

Learn that JSON.parse throws a SyntaxError on malformed text, and why text you loaded is text you did not write so the call belongs in a try...catch.

Worked Example

3.8.13 Worked Example: `try`/`catch` Around a Bad Parse

Week 10
Assignment

3.8.14 Lab: Handle a Malformed JSON String

Week 10

Write a function that parses text and returns a usable fallback instead of letting a bad string stop the program. Auto-graded.

Reading

3.8.15 Reading: Saving by Key

Week 10

Learn how localStorage saves a string under a name you choose, why everything comes back as a string, and why a never-saved key gives null. Read before the save/load labs.

Worked Example

3.8.16 Worked Example: The Whole Pattern

Week 10
Console

3.8.17 Plain English to Pseudocode: Save/Load Round Trip

Week 10

Turn four plain-English steps into pseudocode for loadSettings(): read the key, check for nothing stored, then parse inside a try, with the defaults as the fallback on both exits.

Assignment

3.8.18 Lab: Save a State Object by Key

Week 10

Turn a state object into JSON text and store it under a key, the way a page would keep it between visits. Auto-graded.

Assignment

3.8.19 Lab: Load and Restore a Saved State

Week 10

Read a saved key, cope with a never-saved key, and parse the stored text back into a usable object with a fallback. Auto-graded.

Reading

3.8.20 Reading: Why There Is No `open()` Here

Week 10

Learn why a browser page gets no filesystem access at all, and why reading a local file requires the user to pick it. Read to close out the module before the sandbox example.

Worked Example

3.8.21 Worked Example: What the Browser Sandbox Actually Allows

Week 10
Assignment

3.8.22 Lab: Saving-and-Loading Capstone

Week 10

Combine the whole module: save a state object by key, load it back with the missing-key and bad-parse guards, and print the restored values. Auto-graded.

Assignment

3.8.23 Lab: Adapt the Pattern to a List

Week 10

Apply the save/load pattern to an array of records rather than a single object, and read one record's field back out. Auto-graded.

Quiz

3.8.24 Saving and Loading Data

Week 10

Nine multiple-choice questions on JSON.stringify, JSON.parse, what does not survive a round trip, parse failures, saving by key with localStorage, and the browser sandbox. Checked instantly.

→ View full module page
3.9Chapter 3 Group Performance Assessment
3.10Chapter 3 Individual Performance Assessment
Chapter 4Q1 Synthesis
Chapter 5moshion — Game Development Foundations
5.1Hello Sprite and Movement
Slides

5.1.1 Slides: moSHion Foundations

Week 10

An overview of this module: the canvas, sprites, keyboard input, and the frame loop that runs your code about 60 times a second.

Video

5.1.2 Video: Your first moSHion sketch

Week 10

A 2-and-a-half-minute walkthrough of the canvas, a sprite, and the Run button. Watch before the Hello Sprite lesson.

Reading

5.1.3 Reading: Frame loop: setup() and draw()

Week 10

How moSHion calls setup() once and draw() every frame. Read before 5.1.4 (Worked Example: Minimum Sprite Program).

Worked Example

5.1.4 Worked Example: Minimum Sprite Program

Week 10
Reading

5.1.5 Reading: Canvas: new Canvas(w, h)

Week 10

How new Canvas(w, h) opens the drawing area and why (0, 0) is top-left with y increasing downward. Read before 5.1.6 (Sprite).

Reading

5.1.6 Reading: Sprite: new Sprite(x, y, w, h) + .color

Week 10

How new Sprite(x, y, w, h) creates a rectangle the engine renders for you, and how .color sets its fill. Read before 5.1.7 (lab).

moSHion Lesson

5.1.7 Exploration: Move, resize and recolor a sprite

Week 10

Change one number at a time in a sketch that already works, predict what will move, rerun, and check. Practice from 5.1.5 and 5.1.6. No new code to write.

Reading

5.1.8 Reading: Storing the sprite in a let variable

Week 10

Why you declare a let at file scope and assign the sprite in setup(), and what goes wrong when you create sprites inside draw(). Read before 5.1.9.

Reading

5.1.9 Reading: background(color) wipe rule

Week 10

Why background(color) must be the first call inside draw() to clear the previous frame, and what motion trails look like without it. Read before 5.1.10.

Reading

5.1.10 Reading: Sprite property tour: pos, rotation, layer

Week 10

How to read and write the core sprite properties pos, rotation, and layer after the sprite is created. Read before 5.1.11 (Hello Sprite).

moSHion Lesson

5.1.11 Hello Sprite

Week 10

Your first moSHion sketch: a canvas, a sprite, a background color.

Video

5.1.12 Video: The Frame Loop Explained

Week 10

A 2-and-a-half-minute walkthrough of the frame loop: setup() runs once, draw() runs about 60 times a second, and a sprite moves because draw() changes its x a little each frame. Watch after Hello Sprite.

Reading

5.1.13 Reading: kb.pressing(key)

Week 10

How kb.pressing(key) checks whether a key is held this frame. Read before 5.1.14 (Key names: WASD and the arrow keys).

Reading

5.1.14 Reading: Key names: WASD and the arrow keys

Week 10

The name you give kb.pressing() picks the key: single letters for WASD, words for the arrow keys. Either set works. Read before 5.1.15.

Reading

5.1.15 Reading: Velocity: vel.x and vel.y

Week 10

How sprite.vel.x and vel.y work as pixels-per-frame values the engine integrates into position, and how moving by vel differs from changing pos yourself. Read after 5.1.14.

Reading

5.1.16 Reading: Movement pattern (if / else if / else)

Week 10

The canonical if/else-if/else pattern that maps key presses to velocity changes inside draw(). Read after 5.1.15.

Reading

5.1.17 Reading: The else-to-zero rule

Week 10

Why velocity persists across frames and why the else branch is what stops the sprite. Read after 5.1.16.

Worked Example

5.1.18 Worked Example: Keyboard Movement

Week 10

Teacher-led walkthrough of the if/else-if/else pattern for keyboard movement and the drift-bug. Read before Make it Move.

moSHion Lesson

5.1.19 Lab: Delete the else, watch drift

Week 10

Start from a working WASD movement pattern, delete the two else lines and watch the sprite drift, then restore them and set a speed of your own.

moSHion Lesson

5.1.20 Make it Move

Week 10

Drive a sprite with the keyboard by setting vel.x and vel.y from the keys that are held. Use WASD or the arrow keys, your choice.

Reading

5.1.21 Reading: Words on the canvas: text()

Week 10

How text(words, x, y) puts words on the canvas, what fill() and textSize() change, and why text goes after background(). Read before 5.1.23.

Reading

5.1.22 Reading: Moving on its own: frameCount and sin()

Week 10

frameCount counts the frames, sin() turns that count into a smooth back-and-forth wave, and together they make a sprite move with no key held. Read before 5.1.23.

Assignment

5.1.23 Sprite Playground

Week 10

Build a sprite playground combining canvas, a keyboard-controlled sprite (WASD or arrow keys), auto-motion, and on-screen text. Auto-graded.

Assignment

5.1.24 Frame Loop Writeup

Week 10

Written reflection on setup/draw and the 60fps math. AI-graded with hints.

Challenge

5.1.25 Challenges

Week 10

Pick one or more of the stretch challenges and implement them in the editor. Auto-graded.

moSHion Lesson

5.1.26 Lab: A grid like math (optional)

Week 10

Optional: a preview of an optional mode. Draw a grid over the canvas, then switch it to math mode, where (0, 0) is the centre and y grows up. Nothing after this lab needs it, and it is not graded.

→ View full module page
5.2Physics Feel
Video

5.2.1 Video: Random Numbers and Timers

Week 11

random(6) gives a decimal, floor makes it whole, and frameCount with % makes a beat. A 3-minute walkthrough of the next reading.

Reading

5.2.2 Reading: Random numbers and timers

Week 11

random(max) and random(min, max), floor for whole numbers, and timers made of frames: a repeating beat, a one-shot, and the mistake that stops a one-shot from ever running.

Worked Example

5.2.3 Worked Example: Sparkles on a beat

Week 11

A square appears at a random spot, in a random colour, every 30 frames, and a message arrives once at frame 300. Change the numbers and watch the beat and the moment move.

moSHion Lesson

5.2.4 Lab: A random spot and colour

Week 11

Once a second, move a coin to a random place, roll a whole-number die, and give the coin a random colour from a list.

moSHion Lesson

5.2.5 Lab: A beat and a one-shot

Week 11

Blink a lamp every 30 frames, show a message once at frame 300, and repair a halfway check that sits inside another condition and never runs.

Slides

5.2.6 Slides: Physics Feel

Week 11

Module 5.2 opener: dynamic and static sprites, gravity, the ground-gated jump, bounciness and friction, reaching a goal, and the Pinball Scene you will build.

Video

5.2.7 Video: Gravity Explained

Week 11

Why nothing fell in 5.1: world.gravity.y, and dynamic versus static sprites. A 2-and-a-half-minute walkthrough of the next reading.

Reading

5.2.8 Reading: Gravity

Week 11

world.gravity.y and dynamic vs static sprites. Read before 5.2.10 Lab: Tune Gravity.

Worked Example

5.2.9 Worked Example: Falling Block

Week 11

A dynamic block falls under gravity and lands on the static ground. Read the example, then experiment. Follows 5.2.8 (Reading: Gravity).

moSHion Lesson

5.2.10 Lab: Tune Gravity

Week 11

Try different world.gravity.y values on the same scene and describe how each one feels. Change the value, then write one sentence per value as a comment.

Video

5.2.11 Video: The Jump Explained

Week 11

kb.presses versus kb.pressing, colliding(ground), and the two bugs a jump can have. A 2-minute walkthrough of the next reading.

Reading

5.2.12 Reading: Ground-Gated Actions

Week 11

colliding() and edge-triggered kb.presses vs level-triggered kb.pressing. Read before 5.2.13 Lab: Add a Jump.

moSHion Lesson

5.2.13 Lab: Add a Jump

Week 11

Gate a jump on a key press and a ground check. Auto-graded.

Video

5.2.14 Video: Bounciness and Friction Explained

Week 11

Bounciness from 0 to 1, friction as a slide distance, and how two sprites combine them. A 3-minute walkthrough of the next reading.

Reading

5.2.15 Reading: Bounciness and Friction

Week 11

The two properties and the combining rule. Read before 5.2.16 Bouncy Ball.

moSHion Lesson

5.2.16 Bouncy Ball

Week 11

Learn how bounciness and friction change how sprites feel.

Video

5.2.17 Video: Forces vs Velocity Explained

Week 11

Setting .vel overwrites motion, applyForce adds to it, and mass changes how far a force moves a sprite. A 2-and-a-half-minute walkthrough of the next reading.

Reading

5.2.18 Reading: Forces vs Velocity

Week 11

applyForce vs setting .vel directly. Read before 5.2.19 Lab: Wind Zone.

moSHion Lesson

5.2.19 Lab: Wind Zone

Week 11

Push the player with applyForce inside a conditional zone. Auto-graded.

Video

5.2.20 Video: Delete and Hide Explained

Week 11

a.delete() versus b.visible = false: what stops, what keeps running, and when to use which. A 2-minute walkthrough of the next reading.

Reading

5.2.21 Reading: Cleanup and Delete

Week 11

delete() vs .visible. Read before 5.2.22 Worked Example: The Finished Scene.

Worked Example

5.2.22 Worked Example: The Finished Scene

Week 11
moSHion Lesson

5.2.23 Lab: Reaching the Goal

Week 11

Use the finished scene's distance check to win once with delete(). Auto-graded.

Assignment

5.2.24 Pinball Scene

Week 11

Build a pinball-style scene: static obstacles, a bouncy ball, gravity, and a reset key. Run plays it; the Check button has the AI mark the Quest cards.

Assignment

5.2.25 Vel vs applyForce

Week 11

Why setting .vel every frame fights the physics engine, and when applyForce is the better tool. AI-graded with hints.

Challenge

5.2.26 Challenges: Optional Stretch

Week 11

Add a second, harder-to-reach goal and track a two-goal completion count. Auto-graded.

Video

5.2.27 Video: update() Runs Before Physics

Week 11

The frame order: update, physics, draw, paint, and why a velocity set in update() moves the sprite this frame. A 2-and-a-half-minute walkthrough of the next reading.

Reading

5.2.28 Reading: update() runs before physics

Week 11

moSHion runs a third function on every frame, update(), before the physics step moves the sprites; draw() runs after it. So the rules of the game (keys, movement, the jump) can go in update(), and the picture (background, words) stays in draw(). Read before 5.2.29 Lab: Rules in update(), picture in draw().

moSHion Lesson

5.2.29 Lab: Rules in update(), picture in draw()

Week 11

The jump scene from 5.2.13 does everything in draw(). Split it in two: move the keys, the movement and the jump into update(), which moSHion runs before the physics step, and leave draw() with only the picture.

→ View full module page
5.3Pinball: the table
Reading

5.3.1 Reading: Play the finished game

Week 11

Play the one-player pinball table you will build, with a launcher, two flippers, and a drain. See where each piece fits in the course.

Video

5.3.2 Video: The Pinball Table, Explained

Week 11

Build the square practice table one stage at a time. In 5.5.5 you’ll turn it into the taller arcade cabinet you played in the opening lesson.

Assignment

5.3.3 Plan: Sketch your pinball game

Week 11

Before any code: list the parts of your pinball game, what it must remember, what to build first and what looks hard. AI-graded with hints.

Reading

5.3.4 Reading: From scene to game

Week 11

The scene you built in 5.2.24 is not yet a game. Names the four things that turn one into the other — a goal, a score, a way to lose, a way to start again — and shows the scene with none of them.

Worked Example

5.3.5 Worked Example: The table and the goal

Week 11

Names the table's sprites, adds a gold goal bar on the ball's path, then shows the score that jumps by 33 when the ball rolls across it once — deliberately, because 5.4.1 explains why.

moSHion Lesson

5.3.6 Lab: Drop a bouncy ball

Week 11

Turn gravity on and drop a bouncy ball. It has nothing to land on yet; the next lab builds the walls and the ground.

moSHion Lesson

5.3.7 Lab: Walls and a ground

Week 11

Build two walls and a ground with a gap for the ball to drain through. Your ball from the last lab carries forward.

moSHion Lesson

5.3.8 Lab: A tilted bumper

Week 11

Put a tilted bumper under the ball so it rolls to the right. Your walls and ground carry forward.

moSHion Lesson

5.3.9 Lab: Put a goal on the table

Week 11

Put a gold goal where the ball really goes. The score is drawn but does not change yet — counting is the next lesson. Your table carries forward.

→ View full module page
5.4Pinball: score once
5.5Pinball: lose and start again
5.6Pinball: a sound on a hit
5.7Pinball: labels and popups
5.8Pinball: physics knobs
5.9Pinball: playtest and finish
5.10Flappy: the flap
5.11Flappy: the world scrolls
5.12Flappy: crash, and finish
5.13Snake: grid and steering
5.14Snake: grow
5.15Snake: search
5.16Snake: playtest and extend
5.17Build your own
Chapter 6moshion — Game Mechanics
6.1Pocket: plan and the aim line
6.2Pocket: which way, how fast
6.3Pocket: slow to a stop
6.4Pocket: the pocket
6.5Pocket: playtest and extend
6.6Groups
6.7Overlaps and Collisions
6.8Physics Applications
6.9Animated Sprites and Camera
Slides

6.9.1 Slides: Animation & Camera

Week 16

Animated Sprites and Camera slides cover named textures, camera follow, smoothing with lerp, and layer for render order. Placeholder until the deck is rebuilt from bookSHelf.

Video

6.9.2 Video: Animating a sprite in moshion

Week 16

See a sprite change its visual based on player state. Use the current technique in the worked example and Animated Sprites Sandbox.

Reading

6.9.3 Reading: moSHion docs: Animation

Week 16

moshion docs chapter on Animation. Read before 6.9.9 Animated Sprites Sandbox.

Reading

6.9.4 Reading: Playing a Named Animation

Week 16

Play an animated sprite sheet by assigning its name to sprite.texture.

Reading

6.9.5 Reading: Switching Textures

Week 16

Choose a sprite’s active texture with sprite.texture. Read before 6.9.8 (Worked Example).

Reading

6.9.6 Reading: frameDelay (cycle speed)

Week 16

How sprite.animation.frameDelay = N slows or speeds an animation cycle. Read before 6.9.9 (Animated Sprites Sandbox).

Reading

6.9.7 Reading: sprite.image (single-frame art)

Week 16

How sprite.image = url displays a still image without any animation cycle. Read before 6.9.9 (Animated Sprites Sandbox).

Worked Example

6.9.8 Worked Example: Animating a Sprite

Week 16
moSHion Lesson

6.9.9 Animated Sprites Sandbox

Week 16

Use named textures to show the player standing, moving, or jumping based on input, and play the jump once.

Video

6.9.10 Video: Camera follow explained with a flashlight

Week 16

Why the camera is a coordinate transform, not a 'real' object: the world stays put, only the viewport moves. Watch before 6.9.16 Worked Example: Camera Follow.

Reading

6.9.11 Reading: moSHion docs: Camera

Week 16

moshion docs chapter on Camera. Read before 6.9.16 Worked Example: Camera Follow.

Reading

6.9.12 Reading: camera.x / camera.y

Week 16

How assigning camera.x and camera.y shifts the viewport center each frame. Read before 6.9.13 (Camera-follow pattern).

Reading

6.9.13 Reading: Camera-follow pattern

Week 16

How camera.x = player.pos.x inside draw() locks the viewport onto a moving sprite. Read before 6.9.16 (Worked Example: Camera Follow).

Reading

6.9.14 Reading: Smoothing with lerp

Week 16

How lerp(current, target, t) replaces a hard-set camera follow with a smooth elastic trail. Read before 6.9.17 (Worked Example: Smooth Camera).

Reading

6.9.15 Reading: sprite.layer (render order)

Week 16

How sprite.layer = N controls draw order so HUD elements always render on top of world geometry. Read before 6.9.18 (A15.1 Platformer).

Worked Example

6.9.16 Worked Example: Camera Follow

Week 16
Worked Example

6.9.17 Worked Example: Smooth Camera with lerp

Week 16
Assignment

6.9.18 Side-Scrolling Platformer

Week 16

Combine animated sprites, a camera that follows the player, three or more platforms, working jump mechanics, and a visible end goal into a playable side-scroller. Auto-graded.

Challenge

6.9.19 Challenges

Week 16

Pick one (or more) Animation & Camera stretches: parallax background, mirror the sprite when it walks left, or add vertical camera follow. Auto-graded.

→ View full module page
6.10Save and Load
Slides

6.10.1 Slides: Your Game Forgets: The Problem

Week 16

Save and Load opening slides: why game data disappears on refresh, what persistence means, and the plan for building a save/load system your players can count on. Placeholder until the deck is rebuilt from bookSHelf.

Video

6.10.2 Video: Memory: What Stays, What Disappears

Week 16

A game resets to zero on refresh. Variables live in RAM: gone when the tab closes. Saved data lives on disk, still there tomorrow. This short video contrasts both so you understand what persistence actually means.

Reading

6.10.3 Reading: storeItem: Save Game Data

Week 16

How storeItem(key, value) writes a value into the browser's save slot so it survives page reloads. Your game can remember things between sessions.

Worked Example

6.10.4 Worked Example: Save a High Score on Game Over

Week 16

Step-by-step: build a survival game, detect when the game ends, and use storeItem to save the player's high score so it survives a reload.

Reading

6.10.5 Reading: getItem: Load Saved Data

Week 16

How getItem(key) reads back a value your game saved earlier, as the same type you saved. What to do when nothing was saved yet, and when you still get text, is in 6.10.6.

Reading

6.10.6 Reading: What getItem Gives Back

Week 16

A number you saved with storeItem comes back a number, unlike 3.8's localStorage. Text you saved comes back text: here's when Number() still matters, and the || 0 fallback for the first run.

Worked Example

6.10.7 Worked Example: Load and Display a High Score

Week 16

Read your saved high score on startup, coerce it with Number(), display it next to the current score, and update it when the player beats their record.

Video

6.10.8 Video: More Than a Number: Saving Your Whole Game

Week 16

A high score is one number. But your game has position, level, inventory: many pieces. JSON bundles them together.

Reading

6.10.9 Reading: moSHion docs: JSON.stringify(obj)

Week 16

JSON.stringify takes a JS object and turns it into a string you can store. Think of it as packing your game state into a box.

Reading

6.10.10 Reading: moSHion docs: JSON.parse(str)

Week 16

JSON.parse unpacks a JSON string back into a JS object. It's the reverse of JSON.stringify.

Reading

6.10.11 Reading: moSHion docs: Storing Structured Data

Week 16

The full pattern: build a save object, stringify it, store it. Then getItem, parse, and restore. Complete round-trip.

Worked Example

6.10.12 Worked Example: Save Full Player State

Week 16

Build a game with a moving player, score, and level. Save everything as one JSON object with storeItem.

Worked Example

6.10.13 Worked Example: Restore Full Player State from a Save

Week 16

Load a saved game: getItem, JSON.parse, coerce numbers, then apply to your game objects.

Reading

6.10.14 Reading: moSHion docs: loadJSON is Async

Week 16

loadJSON loads external JSON files (levels, dialogue, config): different from save/load. It's async and needs a callback.

Video

6.10.15 Video: Save Slots: Multiple Save Files

Week 16

One save isn't enough: games have multiple slots. Each slot is just a different key name passed to storeItem/getItem.

Reading

6.10.16 Reading: moSHion docs: removeItem and clearStorage

Week 16

removeItem(key) deletes one save. clearStorage() deletes every save, in every game (saved art is kept). When and how to use each.

Worked Example

6.10.17 Worked Example: Three Save Slots

Week 16

Build three save slots. Each slot is a differently-named key. Press 1/2/3 to save, load with a simple text menu.

Worked Example

6.10.18 Worked Example: Delete and Overwrite a Save Slot

Week 16

Manage save slots: delete old saves with removeItem, confirm before overwriting, handle the empty-slot case.

Video

6.10.19 Video: New Game or Continue?

Week 16

If a save exists, show 'Continue'. If not, only 'New Game'. The title screen pattern every game uses.

Worked Example

6.10.20 Worked Example: Title Screen Detects Existing Saves

Week 16

Build a title screen that checks for a save on startup. If save exists, show 'Press C to Continue'. Always show 'Press N for New Game'.

Reading

6.10.21 Read the Chart: Does Continue Show Up?

Week 16

No drawing. Read the title-screen save check and answer five questions about what a first-time player sees.

Worked Example

6.10.22 Worked Example: Confirm Before Overwriting a Save

Week 16

When the player tries to save over an existing slot, show an 'Are you sure?' prompt before writing.

Video

6.10.23 Video: Your Game, Automatically Saved

Week 16

Not every save needs a button press. Auto-save triggers on level transitions, checkpoints, or a timer: the player doesn't think about it.

Reading

6.10.24 Reading: Checkpoint Saves: Save on Milestones

Week 16

An auto-save fires when something important happens: reaching a checkpoint, finishing a level, hitting a score milestone.

Worked Example

6.10.25 Worked Example: Auto-Save on Level Complete or Timer

Week 16

Implement two auto-save triggers: when the player reaches a level-complete zone, and a timer-based save every 30 seconds.

Assignment

6.10.26 Save System: Build Save/Load with Slots

Week 16

Graded: build a game with a complete save system, at least 3 save slots, load functionality, auto-save on level complete, and a Continue option on the title screen.

Challenge

6.10.27 Challenges: Extended Save Features

Week 16

Extend your save system: save file previews (show slot contents before loading), save timestamps, multiple profiles, or deleting this game's saves with double-confirmation.

→ View full module page
6.11Game State Machines
Slides

6.11.1 Slides: One Game, Many Screens

Week 17

Game State Machines opening slides: title screen, gameplay, pause, game over. Every screen is a state. One variable controls which screen is active. Placeholder until the deck is rebuilt from bookSHelf.

Video

6.11.2 Video: State Machines in Games

Week 17

Every game has states: title → play → game over → title. A state machine is just a variable that remembers which screen you're on.

Reading

6.11.3 Reading: MDN: The switch Statement

Week 17

switch is like if/else but cleaner when checking one variable against many values. Syntax: switch(variable) { case VALUE: ... break; }

Reading

6.11.4 Reading: moSHion docs: switch in draw()

Week 17

In moSHion games, switch goes inside draw(). Each frame, it checks the state variable and draws the right screen.

Worked Example

6.11.5 Worked Example: switch with Three Cases

Week 17

A plain switch with three cases that each draw different text. Not a game yet, just getting comfortable with the syntax.

Reading

6.11.6 Reading: break and default in switch

Week 17

break exits the switch; without it, execution falls through to the next case. default handles unexpected values.

Reading

6.11.7 Reading: moSHion docs: The state Variable

Week 17

One variable controls which screen is visible. Every frame, draw() checks state to decide what to render. This is the single source of truth for your game's screen.

Worked Example

6.11.8 Worked Example: One Variable, Many Screens

Week 17

Build three distinct screens: red, green, blue backgrounds with different text: all controlled by one state variable with switch.

Reading

6.11.9 Reading: Naming States: Conventions

Week 17

Use lowercase strings for state names: 'title', 'play', 'pause', 'gameover'. Be consistent. Good names make the switch statement self-documenting.

Video

6.11.10 Video: Building a Title Screen

Week 17

A title screen is just a state. It shows the game name, maybe instructions, and waits for the player to press a key to start playing.

Worked Example

6.11.11 Worked Example: Title Screen with Start Button

Week 17

Build a title screen state that shows the game name and 'Press ENTER to start'. When they press Enter, change state to 'play'.

Video

6.11.12 Video: Game Over and Restart

Week 17

The game over screen shows the final score and 'Press R to restart'. Restart means resetting variables + changing state back to 'play' (or 'title').

Worked Example

6.11.13 Worked Example: Three-State Machine: Title, Play, Game Over

Week 17

The complete beginner state machine: title screen → gameplay → game over → restart. The classic arcade loop.

Console

6.11.14 Plain English to Pseudocode: The Three-State Machine

Week 17

Turn the plain-English rules of a three-state game into pseudocode: route by state, draw first, then ask whether to change state.

Reading

6.11.15 Reading: moSHion docs: Input-Driven Transitions

Week 17

Input-driven transitions happen when the player presses a key. Title → Play (press Enter), Play → Pause (press P). The player is in control.

Worked Example

6.11.16 Worked Example: Keyboard-Driven State Changes

Week 17

Build a game where every state transition is triggered by the keyboard: Enter (start), P (pause/unpause), Escape (quit to title).

Reading

6.11.17 Reading: moSHion docs: Condition-Driven Transitions

Week 17

Condition-driven transitions happen automatically when something in the game changes. Score ≥ 100 → 'win', health ≤ 0 → 'gameover'. The game state triggers it.

Worked Example

6.11.18 Worked Example: Score Threshold Triggers Game Over

Week 17

Implement condition-driven transitions: score reaches 50 triggers a win screen, health drops to 0 triggers game over. The game decides when states change.

Video

6.11.19 Video: More States: Pause, Inventory, Settings

Week 17

Real games have more than 3 states. Pause freezes the action. Inventory shows items. Settings adjusts volume. All use the same switch pattern you already know.

Worked Example

6.11.20 Worked Example: Adding a Pause State

Week 17

Add a pause state to your game. When paused, stop movement and physics, show a PAUSED overlay. Press P to toggle pause on and off.

Console

6.11.21 Fix the Broken Pseudocode: the Pause State

Week 17

Repair half-finished pseudocode for a pause feature: give the not-playing frame its own branch, wire in the pause screen, stop a step jumping to itself, and add the way out.

Worked Example

6.11.22 Worked Example: Win Screen State

Week 17

A win screen shows when the player reaches the goal. It's a distinct state with congratulations, final stats, and a 'Play Again?' option.

Video

6.11.23 Video: States Decide When to Save

Week 17

States and saves work together: when the player reaches 'gameover', auto-save their score. When they hit 'win', save their victory. States trigger saves.

Worked Example

6.11.24 Worked Example: Save on State Transition

Week 17
Worked Example

6.11.25 Worked Example: Continue Loads the Correct State

Week 17
Assignment

6.11.26 Game States: State Machine with Persistence

Week 17

Graded: build a game with at least 4 states (title, play, pause, gameover) with full save/load integration. Saves trigger on state transitions. Continue restores the right state.

Challenge

6.11.27 Challenges: Extended State Features

Week 17

Extend your state machine: animated transitions, a loading screen state, state history (undo last transition), or an options/settings state that modifies gameplay.

Video

6.11.28 Video: What's Next: Looking Ahead to Unit 3

Week 17

You've built save systems and state machines: real game infrastructure. Unit 3 preview: what comes after the fundamentals.

→ View full module page
6.12Advanced Input
Slides

6.12.1 Slides: Advanced Mechanics: One Last Toolkit

Week 17

Advanced Input opening slides: the input ideas you need before the capstone: mouse position, click vs. held, dragging, and two-player key schemes. Joints and the slingshot pattern follow in Unit 6.13. Placeholder until the deck is rebuilt from bookSHelf.

Video

6.12.2 Video: Why Mechanics Matter for the Capstone

Week 17

This is the last content unit before you design your own game. Mouse input, joints, and the slingshot pattern are the final building blocks: learn them here and you'll have everything you need to pitch and build a real project.

Reading

6.12.3 Reading: moSHion docs: mouse.x and mouse.y

Week 17

mouse.x and mouse.y give you the cursor's position on the canvas every frame. Read this before the mouse input worked examples.

Reading

6.12.4 Reading: moSHion docs: mouse.pressing()

Week 17

mouse.pressing() is true every frame the mouse button is held down. Read this before 6.12.5 so you understand the held vs. one-shot difference.

Reading

6.12.5 Reading: moSHion docs: mouse.presses()

Week 17

mouse.presses() is true on exactly one frame: the moment the button first goes down. Read this after 6.12.4 to see how one-shot input differs from held input.

Reading

6.12.6 Reading: Hit-Testing a Sprite with the Mouse

Week 17

A hit-test checks whether the cursor is currently over a sprite. This technique gates click-and-drag: the drag only starts when the mouse is on the sprite.

Worked Example

6.12.7 Worked Example: Click to Spawn a Sprite

Week 17
Video

6.12.8 Video: Drag and Release

Week 17

Clicking is one-shot, but dragging follows the cursor across frames, and physics will fight you if you don't know the trick. This video shows the snap-and-zero-velocity pattern that makes a drag feel smooth before you code it yourself.

Reading

6.12.9 Reading: Snap a Sprite to the Cursor

Week 17

How to move a sprite exactly to the cursor position each frame during a drag. Zeroing the velocity is the step that keeps physics from fighting your snap.

Worked Example

6.12.10 Worked Example: Drag a Sprite Around

Week 17
Console

6.12.11 Fix the Broken Pseudocode: Dragging a Sprite

Week 17

Repair half-finished pseudocode for dragging: give the mouse-up frame its own branch, put the velocity reset where it belongs, and stop a step jumping to itself.

Video

6.12.12 Video: Two-Player Local Input

Week 17

One keyboard, two players: WASD on the left, arrow keys on the right, each with their own sprite and score. This video shows the pattern once so you can wire it up in A17.1 without guessing.

Reading

6.12.13 Reading: Two Key Schemes, Independent State

Week 17

Two players on one keyboard means two separate key sets and two separate sets of variables: one for each player. Read this before 6.12.16 Worked Example: Two Paddles, Two Schemes.

Reading

6.12.14 Reading: moSHion docs: sprite.bounciness

Week 17

sprite.bounciness controls how much energy a sprite keeps after a collision: 0 is a dead thud, 1 is nearly lossless. Read this before 6.12.15 Worked Example: Bounciness Comparison.

Worked Example

6.12.15 Worked Example: Bounciness Comparison

Week 17
Worked Example

6.12.16 Worked Example: Two Paddles, Two Schemes

Week 17
→ View full module page
6.13Joints
Video

6.13.1 Video: Joints in moshion

Week 17

Three joint types in five minutes: a distance joint keeps two sprites a fixed length apart, a hinge lets one pivot around another, and a slider rides a track. You don't need to master all three, just watch and pick the one that fits your game.

Reading

6.13.2 Reading: moSHion docs: DistanceJoint

Week 17

How DistanceJoint constrains two sprites to stay at a fixed distance from each other. Read this before the pendulum worked example.

Worked Example

6.13.3 Worked Example: Pendulum with DistanceJoint

Week 17
Reading

6.13.4 Reading: moSHion docs: HingeJoint

Week 17

How HingeJoint pins two sprites to a shared pivot point so they rotate around it. Read this before the rotating-arm worked example.

Worked Example

6.13.5 Worked Example: Rotating Arm with HingeJoint

Week 17
Reading

6.13.6 Reading: moSHion docs: joint.delete()

Week 17

How joint.delete() releases a constraint at runtime so previously-joined sprites become independent. This is the release step in the slingshot pattern.

Reading

6.13.7 Reading: moSHion docs: applyForce(fx, fy)

Week 17

applyForce(fx, fy) adds a one-frame impulse to a sprite: the physics engine turns it into motion. Read this before 6.13.9 Worked Example: Launch a Sprite with applyForce.

Reading

6.13.8 Reading: Vector from A to B

Week 17

Two numbers: dx and dy: encode the direction from one sprite to another. This is the math behind every force that points somewhere on purpose. Read this before 6.13.9 Worked Example: Launch a Sprite with applyForce.

Worked Example

6.13.9 Worked Example: Launch a Sprite with applyForce

Week 17
Video

6.13.10 Video: The Slingshot Pattern

Week 17

This is the moment the unit snaps together: a joint holds the ball, you drag it back with the mouse, release removes the joint, and a force vector launches it toward the target. Watch the whole pattern before you read the code.

Worked Example

6.13.11 Worked Example: Slingshot End-to-End

Week 17
Console

6.13.12 Plain English to Pseudocode: The Slingshot

Week 17

Turn the plain-English rules of a slingshot into pseudocode: grab, stretch and release, guarded by one variable, with the force applied in exactly one frame.

Challenge

6.13.13 Challenges: SliderJoint, Trebuchet, Swinging Rope

Week 17

Three optional stretch prompts for Unit 6.13: build a SliderJoint piston sandbox, a trebuchet that uses a DistanceJoint + HingeJoint together, or a swinging rope chain with three or more HingeJoints.

Assignment

6.13.14 Two-Player Pong-Sumo

Week 17

Graded: build a two-player Pong-Sumo game: two paddles, one ball, push the ball past the opponent to score. Incorporates two-player input, push-collision physics, a win condition, and at least one joint. Auto-graded.

Video

6.13.15 Video: Wrap and Capstone Preview

Week 17

You've built every piece: mouse input, joints, forces, two-player games, state machines, saves. This short video closes Units 6.12 and 6.13 and previews what Unit 8.1 asks you to do: design and pitch your own game from scratch.

→ View full module page
6.14Grids and Tile Maps
Assignment

6.14.1 Plan: Break the Coin Maze into parts

Week 16

Before any code: list the parts of the Coin Maze, what the game must remember between frames, what to build first and what looks hard. AI-graded with hints.

Reading

6.14.2 Reading: A map is rows of text

Week 16

A level can be written as rows of text and built with Tiles. Covers the legend, Group defaults, the centre rule for x and y, and level.delete().

Worked Example

6.14.3 Worked Example: A level from text

Week 16

A small level built from six rows of text. Change a letter, the legend or the tile size and watch what each one controls.

moSHion Lesson

6.14.4 Lab: Build the maze

Week 16

The screen is empty: three Groups, a map and a player, but no level. Set the defaults on walls, coins and the goal, then build the whole maze from rows of text with Tiles. You can then walk it, and the corner counts the coins left (5).

Reading

6.14.5 Reading: Reading a map as data

Week 16

The map is also data your own code can read. Scan it for a letter, turn a row and column into pixels and a pixel back into a row and column with floor, and check the row and column exist first.

moSHion Lesson

6.14.6 Lab: Find the start

Week 16

The maze is built, but the player always stands at a fixed spot in the corridor instead of on the P in the map. Scan the map for the P, turn its row and column into pixels, put the player there, and write the way back from pixels to a tile.

moSHion Lesson

6.14.7 Lab: Coins and the goal

Week 16

The player walks the maze but the coins do nothing and the goal never opens. Pick up each coin when the player touches it, count it in the score, and let the goal win only when no coin is left.

moSHion Lesson

6.14.8 Lab: The next level

Week 16

The game has three maps in a list called levels, but the screen is blank and the goal ends nothing. Write loadLevel(n) to throw the old level away and build level n, then make the goal move on to the next level, and win after the last one.

Reading

6.14.9 Reading: A grid is data

Week 16

A grid you can change is an array of arrays, and the screen is a picture drawn from it every frame. Build one, draw it with rect, turn a click into a row and a column, check the bounds, flip a cell and count.

moSHion Lesson

6.14.10 Lab: Light the grid

Week 16

An 8 by 8 grid of lights kept as data. The starter has the canvas, the draw loop and the words, and every function you need is there but empty. Build the grid, draw it from the data, flip a cell on a click, and count the lit cells.

moSHion Lesson

6.14.11 Lab: A wall of bricks

Week 16

A wall of 40 bricks kept as an array of arrays of 1s and 0s. The drawing, the mouse and the words are done. Build the wall with two loops, find the brick under a pixel (the wall starts 60 pixels down), and count the bricks left.

Assignment

6.14.12 Playtest and reflect: Coin Maze and bricks

Week 16

Play your finished Coin Maze to the end and clear your brick wall, try to break each, find one surprise, link it to your code and choose one change. AI-graded with hints.

Quiz

6.14.13 Check: Grids and tile maps

Week 16

Seven multiple-choice questions on rows and columns, pixels and cells, the offset, bounds and level.delete(). Checked instantly.

moSHion Lesson

6.14.14 Challenges: Make it yours

Week 16

The brick wall is complete. Change one rule of your own: points by row, two-hit bricks, or a wall read from rows of text. Pick one; add an idea of your own on top if you like.

→ View full module page
6.15Sound and Music
Reading

6.15.1 Reading: Sound in a sketch

Week 19

A sound is a file the sketch downloads: load it once in setup(), play it on an event. play() starts a copy, loop() keeps one going, .volume, .rate and masterVolume() set how it sounds, and a browser may make no sound until the player clicks or presses a key.

Worked Example

6.15.2 Worked Example: A sound board

Week 19

One chime at four speeds on the keys 1 to 4, and a tune that T loops and X stops. Hold a key with kb.pressing, press T three times, and start the tune in setup() to see what each line does.

moSHion Lesson

6.15.3 Lab: A sound on an event

Week 19

Star catch makes no sound yet. Load two sounds once, in setup(), then play a chime for each star you catch and a low thud for each one you miss, each in the one place where its event happens once.

moSHion Lesson

6.15.4 Lab: Music, volume and a mute key

Week 19

A tune loops under Star catch, quieter than the effects. The up and down keys step its volume between 0 and 10, and M turns every sound off and on again.

moSHion Lesson

6.15.5 Lab: A sound that varies

Week 19

The same sound every time tires the ear. Give each catch a random pitch with .rate and random(), and give each miss one of three thuds picked at random from a list.

Reading

6.15.6 Reading: Music that follows the game

Week 19

Music changes when the screen changes, once, in the one function every change of screen goes through: stop the old music, then start the new screen's. One tune gives four moods with .rate. Sound settings are saved when they change and loaded at the start, with !== null so a saved 0 is kept.

moSHion Lesson

6.15.7 Lab: Music for every screen

Week 19

Star catch has a title, the game, a win and a loss, and every change of screen goes through goTo(next). Make goTo change the music: stop what was playing, loop the tune on the title and in the game, and play it once for a win or a loss.

moSHion Lesson

6.15.8 Lab: A settings screen that remembers

Week 19

A sound options screen: up and down step the level, M mutes, and both are saved with storeItem when they change and loaded with getItem when the game starts, so the game remembers them.

Quiz

6.15.9 Check: Sound and music

Week 19

Eight multiple-choice questions on the browser's rule, loading once, play and loop, rate, a random pick, stopping the music on a new screen, and a saved 0. Checked instantly.

moSHion Lesson

6.15.10 Challenges: Make it yours

Week 19

Your Star catch has sound, music and saved options. Add one sound rule of your own: a streak that climbs, a chime that comes from where you caught it, or chords cut from one file. Pick one; add an idea of your own on top if you like.

→ View full module page
6.16Sling: plan and the arm
6.17Sling: launch
6.18Sling: out and gone
6.19Sling: hits and a budget
6.20Sling: five shots
6.21Sling: playtest and extend
6.22Trail: plan and the path
6.23Trail: roll and take turns
6.24Trail: squares that do something
6.25Trail: play online
6.26Trail: playtest and extend
6.27Checkers: plan and the board
6.28Checkers: pick up and move
6.29Checkers: jumps
6.30Checkers: kings and the win
6.31Checkers: play online
6.32Checkers: playtest and extend
Chapter 7Q2 Synthesis — Game Capstone
7.1Classes and Instances
Slides

7.1.1 Slides: Object-Oriented Programming

Week 12

Classes and Objects slides: this, and procedural vs OOP. Placeholder until the deck is rebuilt from bookSHelf.

Video

7.1.2 Video: What new Sprite() actually does

Week 12

4-min DevTools walkthrough. Opens a running moSHion sketch, inspects a Sprite instance, and names what a class is. Watch before the DevTools reveal example.

Reading

7.1.3 Reading: Class and instance

Week 12

The words class and instance and how they relate: a class is a blueprint; new builds one instance from it. Read before 7.1.4.

Reading

7.1.4 Reading: The new operator

Week 12

What new does mechanically: allocate, run constructor, return. Read right after 7.1.3.

Reading

7.1.5 Reading: constructor and its parameters

Week 12

How the constructor receives arguments from new and stores them on this. Read right after 7.1.4.

Worked Example

7.1.6 Worked Example: The parts of a class

Week 12

One small class with each part labelled: the class name, the constructor, its parameters, and the properties it stores on this. Follows 7.1.5 (Reading: constructor and its parameters).

Worked Example

7.1.7 Worked Example: You've been using classes

Week 12
Reading

7.1.8 Reading: Properties: data on this

Week 12

A property is data stored on a single instance via this.name = value. Read before the property labs.

moSHion Lesson

7.1.9 Lab: Read a property

Week 12

Read b.color and b.size off a Box instance and print them to the on-canvas console using console.log. First practice with dot-notation reads.

moSHion Lesson

7.1.10 Lab: Write a property

Week 12

Mutate b.color on a space-bar press to practice assigning a new value to an instance property. First practice with dot-notation writes.

moSHion Lesson

7.1.11 Lab: Two sprites, two property values

Week 12

Instantiate b1 and b2 from the same class with different colors, then mutate only b1 to confirm each instance's state is independent.

Reading

7.1.12 Reading: this is a noun

Week 12

this always refers to one specific thing: the instance the method was called on. Read before the substitution rule example.

Worked Example

7.1.13 Worked Example: this is a pronoun

Week 12
moSHion Lesson

7.1.14 Your Turn: Build a Sprite

Week 12

Low-stakes autograded practice. Instantiate the Sprite class twice (rectangle form and circle form), set properties on each instance, and give one sprite a stroke. Bridges the 7.1.7 / 7.1.13 worked examples and the 7.2.11 Enemy class worked example.

Worked Example

7.1.15 Worked Example: Sprite Showcase

Week 12

A tour of the Sprite class re-read as OOP. Every new Sprite(...) is a constructor call; every .color / .stroke is a property on an instance.

moSHion Lesson

7.1.16 Your Turn: Fill in a Constructor

Week 12

Low-stakes autograded practice. The class shell is given; you write the constructor body that stores three arguments on this, then build two instances with different values. Follows 7.1.15 (Worked Example: Sprite Showcase) and comes before the Enemy class in 7.2.11.

→ View full module page
7.2Writing Your Own Classes
Reading

7.2.1 Reading: Methods: functions that live on a class

Week 13

Method declaration syntax: inside a class body, methods are written without the function keyword. Read before the method labs.

Video

7.2.2 Video: The this keyword

Week 13

3-min whiteboard walkthrough of this inside methods. Shows why this.color and this.hp refer to the specific instance the method was called on.

moSHion Lesson

7.2.3 Lab: Method with no params

Week 13

Write Counter.tick(): a method that takes no arguments and mutates this.n. First method you write from scratch.

moSHion Lesson

7.2.4 Lab: Method with parameters

Week 13

Add Counter.addBy(n): a method that takes an argument and uses it to increment this.n. Keys 1/2/3 add different amounts.

moSHion Lesson

7.2.5 Lab: Method that returns a value

Week 13

Add Counter.isHigh() which returns true when this.n > 10. The driver (the code in draw()) uses the return value to color the display red.

moSHion Lesson

7.2.6 Lab: A method calling this.otherMethod()

Week 13

Write Counter.bigStep() which calls this.addBy(5) and returns this.isHigh(): one method dispatching another on the same instance.

Console

7.2.7 Plain English to Pseudocode: A Method That Calls a Method

Week 13

Turn five plain-English steps into pseudocode: one decision, two calls to other methods, and a step that runs either way.

Reading

7.2.8 Reading: Why this.sprite, not extends Sprite

Week 13

Composition over inheritance: why wrapping a Sprite as this.sprite is safer than inheriting from it. Read before the sprite mutation labs.

moSHion Lesson

7.2.9 Lab: Mutate this.sprite.x from a method

Week 13

Write Mover.moveRight(dx) which adds dx to this.sprite.x, reaching through composition to move the wrapped sprite.

moSHion Lesson

7.2.10 Lab: Cleanup with this.sprite.delete()

Week 13

Write Bubble.pop() which calls this.sprite.delete() so the object removes its own sprite on click.

Worked Example

7.2.11 Worked Example: Write an Enemy class (integration)

Week 13
moSHion Lesson

7.2.12 Lab: Three Enemies in three variables

Week 13

Instantiate e1, e2, and e3 from the Enemy class at three different positions: three independent instances, each in its own named variable.

moSHion Lesson

7.2.13 Lab: An array of Enemies

Week 13

Store five Enemy instances in a single array by pushing new Enemy(...) calls into enemies: practice managing many instances without separate named variables.

moSHion Lesson

7.2.14 Lab: Loop over an array of instances

Week 13

Write a for...of loop in draw() that calls .render() on each enemy: dispatching a method to every element in the array with one loop.

Reading

7.2.15 Reading: Parallel Arrays vs Classes

Week 13

Side-by-side comparison of the same problem (an 'enemy fleet') solved two ways: with parallel arrays (procedural) and with an array of class instances (OOP). Read between the Enemy class example and the Procedural-vs-OOP example.

Worked Example

7.2.16 Worked Example: Procedural vs OOP side-by-side

Week 13
Reading

7.2.17 Read the Charts: Three Variables or Three Objects

Week 13

The same feature drawn twice, procedural and object-oriented. No drawing: read both and answer what happens when a fourth enemy arrives.

Reading

7.2.18 Reading: When to reach for OOP (3-question checklist)

Week 13

Three yes-or-no questions that tell you whether a class is the right tool. Read after the Procedural vs OOP example.

Assignment

7.2.19 Collectible Class

Week 13

Write a Collectible class, instantiate at least 5, and detect overlap with the player. SLO-2 lab: the class is the point. Auto-graded.

Assignment

7.2.20 Procedural vs OOP Writeup

Week 13

Comparison of procedural and object-oriented programming.

Reading

7.2.21 Reading: Encapsulation, inheritance, polymorphism (vocabulary only)

Week 13

Name the three OOP pillars you'll encounter in downstream courses: no implementation required this week. Read at the close of 7.2.

Challenge

7.2.22 Challenges

Week 13

Pick one (or more) OOP stretch challenges: extend your Enemy class, write a Player class, or try subclassing with extends. Auto-graded.

→ View full module page
7.3Inside a Class
Reading

7.3.1 Reading: Three places a variable can live

Week 14

A method can reach a global, a property on this, or a local it declares itself. Only the property survives the call. Extends 3.2.24's local-versus-global with the third place, and says why a parameter dies too.

Worked Example

7.3.2 Worked Example: The counter that resets

Week 14

A tick() method that declares let n = 0 and writes it out again, so the number on screen never moves. Then the one-line fix: change this.n directly.

moSHion Lesson

7.3.3 Lab: Move the counter onto this

Week 14

The starter's tick() changes a local, so the number on screen stays at 1. Make the change land on this.n so it survives the call.

moSHion Lesson

7.3.4 Lab: Share one number between two methods

Week 14

add() declares its own let step = 3; undo() types the 3 again. A local in one method is invisible to the next, so the two numbers can drift. Put the step on this in the constructor and both methods use it.

Reading

7.3.5 Reading: Who may change a property

Week 14

A property is open: any code holding the object can write it. Shows health counting down past zero while the enemy is still on screen, and the alternative — a method that owns the rule, so the outside asks the class instead of doing its arithmetic.

Worked Example

7.3.6 Worked Example: The number anyone can set

Week 14

The same Enemy twice: once with draw() doing the subtraction and the death check, once with takeHit(n) and isAlive() inside the class. Ends by trying to break the class from outside, to show what encapsulation does and does not promise in JavaScript.

Quiz

7.3.7 Check: Scope and access

Week 14

Six multiple-choice questions on where a variable lives, why a local cannot be shared between methods, and what a method that owns a rule buys you. Checked instantly.

moSHion Lesson

7.3.8 Lab: takeHit with a floor at zero

Week 14

The enemy starts at 5 health and is hit for 2 at a time. Write takeHit(n) so that health comes off and never goes below zero — the rule lives in the class, not in the scene.

moSHion Lesson

7.3.9 Lab: Give the class its own isAlive()

Week 14

The scene asks hp > 0 twice, by hand. Write isAlive() on the class and ask it instead, so the question 'is this enemy still up?' has exactly one answer in one place. What you see on screen does not change.

Reading

7.3.10 Reading: A parameter that is another object

Week 14

In a.distanceTo(b) the method has two instances in play: this is the receiver, other is the parameter. Shows where that symmetry ends — player.hit(enemy) and enemy.hit(player) mean opposite things.

Worked Example

7.3.11 Worked Example: player.hit(enemy)

Week 14

The scene hits the enemy directly, then a Player class takes over with hit(other) calling other.takeHit(this.power). Changing the player's power then changes the fight without touching Enemy.

moSHion Lesson

7.3.12 Lab: Write hit(other)

Week 14

The enemy already knows how to take a hit; the player is missing its half of the exchange. Write hit(other) so the receiver's power is applied to the object passed in.

moSHion Lesson

7.3.13 Lab: Reap the dead with filter

Week 14

Dead enemies stay in the array, so the list never shortens and the next hit lands on a corpse. Build a new list of the living with filter and store it back in enemies.

Reading

7.3.14 Reading: One value shared by every instance

Week 14

A static property belongs to the class rather than to an instance: Enemy.spawned counts every enemy ever built, and e.spawned is undefined. Also separates this keyword from moSHion's unrelated 'static' body type.

Worked Example

7.3.15 Worked Example: Enemy.spawned

Week 14

A static spawned counter bumped in the constructor, so it counts every enemy ever created rather than the ones still on screen. Also shows what resetting it from draw() every frame does.

moSHion Lesson

7.3.16 Lab: Count your spawns

Week 14

The scene already prints Enemy.spawned, which is undefined because nothing declares it. Add a counter that belongs to the class and bump it in the constructor, so every enemy ever built is counted.

Worked Example

7.3.17 Worked Example: The wave spawner

Week 14

Assembles the module: a frameCount timer spawns enemies, the array is reaped with filter, and a wave only arrives once the field is clear. Closes with a table of which job belongs to the class, the array, and the scene.

moSHion Lesson

7.3.18 Lab: Build a wave

Week 14

Build the spawner yourself: a frameCount timer that sends three enemies only when the field is clear, a hit that goes to the first one, and a filter that reaps the dead. Uses every idea in the module.

Console

7.3.19 Your Turn: Where the state lives

Week 14

Three numbers from the wave spawner, and for each one: a local, a property on this, or a class variable — plus one sentence on why. Formative, AI-checked, no points.

Quiz

7.3.20 Unit 5 Check: classes, objects and methods

Week 14

Eight multiple-choice questions closing Unit 5: class versus instance, the constructor, this, method syntax, separate state on two instances, arrays of instances, where a variable lives, and what a class variable is. Checked instantly.

→ View full module page
7.4Defender: the ship, and shots
7.5Defender: hits, and a round
7.6Defender: many enemies
7.7Defender: the hit loop
7.8Defender: waves and the cost
7.9Defender C: design and the classes
7.10Defender C: a spawner
7.11Defender C: playtest and check
7.12Breakout: plan, ball and paddle
7.13Breakout: bricks and edges
7.14Breakout: the game
7.15Breakout: playtest and extend
7.16Quest: plan and the fighters
7.17Quest: trade blows
7.18Quest: choices
7.19Quest: a run of enemies
7.20Quest: duel online
7.21Quest: playtest and extend
Chapter 8

Report an issue

or paste one — optional, max 2 MB

Your page, lesson, and current code are attached automatically.