shCode

Choose a lesson

Chapter 1JavaScript Fundamentals7 modules
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. Served live from bookSHelf; a push there updates this deck with no shCode rebuild.

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.

Flowchart

1.5.28 Chart the Even-or-Odd Test

Five shapes: get a number, ask whether it is even, print one of two answers, rejoin. Your first chart, ungraded.

Reading

1.5.29 Reading: The Class Flowchart Convention

The rule for the rest of the course: every graded build opens with a flowchart, and the flowchart goes first. What gets checked, what does not, and how big a chart should be.

Assignment

1.5.30 Your First Flowchart (Part 1)

Chart the printer-credit rule using only the three shapes the book teaches. The first and gentlest run of the flowchart gate: nothing is graded, and you can redraw as often as you like.

Assignment

1.5.31 Implement Your Plan (Part 2)

Turn the chart you just passed 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 Flow7 modules
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
Flowchart

2.1.5 Chart the Code, if / else

Week 5

Draw the if/else you just traced as a flowchart. One diamond, two labelled exits, both branches rejoining.

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

Algorithms and Loops slides. Placeholder until the deck is built from the book.

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
Flowchart

2.2.6 Chart the Code: Largest of Three

Week 6

You just wrote the largest-of-three algorithm as code. Now draw the same algorithm as a flowchart, without looking at the code.

Assignment

2.2.7 Flowchart a Decision

Week 6

Draw the ticket-price algorithm as a flowchart. One start, one decision diamond with two labelled exits, one end. Green here unlocks 2.2.8 A2.2.1 (Part A).

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
Flowchart

2.2.11 Chart the Code: A for-loop That Accumulates

Week 6

Draw the sum-1-to-5 loop as a flowchart using the loop-setup hexagon, and get the return arrow landing in the right place.

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.

Flowchart

2.2.18 Fix the Broken Chart

Week 6

A flowchart arrives with five red checks and one actual mistake. Find the mistake, and learn to read the checker instead of guessing.

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

The Switch Statement slides. Placeholder until the deck is built from the book.

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
Flowchart

2.3.6 Chart the Code: a switch is a chain of diamonds

Week 6

Draw a three-case switch as a flowchart and see why break matters: without it, the arrows fall straight into the next case.

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

Loop Control and Nested Loops slides. Placeholder until the deck is built from the book.

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
Flowchart

2.4.7 Chart the Code: do...while

Week 6

Draw a do...while loop as a flowchart and see why the diamond sits at the bottom instead of the top.

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
Flowchart

2.4.11 Chart the Code: Search Until Found

Week 6

Draw a while (true) + break search as a flowchart. The loop has no condition of its own: the diamond inside the body is the only way out.

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
Flowchart

2.4.15 Chart the Code: continue Skips, Doesn't Leave

Week 6

Draw the skip-the-evens loop and route continue's arrow back to the hexagon, not to End. Compare it against a break chart.

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
Flowchart

2.4.22 Fix the Infinite Loop

Week 6

A chart arrives whose diamond only has one exit: the loop can never leave. Add the missing branch so a reader can see where it stops.

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
Flowchart

2.4.26 Chart the Code: Nested Loops

Week 7

Draw the row/col nested loop with two loop-setup hexagons, one nested inside the other's body.

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

Handling Errors with try/catch slides. Placeholder until the deck is built from the book.

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.

Flowchart

2.5.7 Chart the Code: try/catch as a Flowchart

Week 7

Draw try/catch as a flowchart: attempt a step, then branch on whether it failed.

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
Flowchart

2.5.17 Chart the Code: Validate Before You Trust

Week 7

Draw two validation checks in a row, each throwing on the branch that fails.

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 Data10 modules
3.1Functions: Definition and Calls
Slides

3.1.1 Slides: Functions

Functions: Definition and Calls slides. Placeholder until the deck is built from the book.

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 Chart Before You Refactor

Redraw your grade-advisor plan with each function as one double-rail shape. The gate for A3.1.1: chart 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 Chart What You Built

Week 7

Draw the grade-advisor program you just refactored, using the double-rail shape for decideGrade() and printAdvice(). The after-chart to 3.1.12's before-chart.

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

Parameters and Return Values slides. Placeholder until the deck is built from the book.

Reading

3.2.2 Reading: Parameters & Return Values

Week 7

Parameters let you pass inputs into a function. return sends a value back out so you can store or use 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.

Reading

3.2.6 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.7 Lab: findRectangleArea (multi-parameter)

Week 7

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

Flowchart

3.2.8 Chart the Code: Tracing Parameter Values

Week 7

Draw a program that passes a value into a function with a parameter, and get the call shape and the value flow right.

Reading

3.2.9 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.10 Worked Example: return instead of print

Week 7
Reading

3.2.11 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.12 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.13 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.14 Worked Example: Which Should a Function Do?

Week 7
Assignment

3.2.15 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.

Reading

3.2.16 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.17 Worked Example: Chaining Two Functions

Week 7
Flowchart

3.2.18 Chart the Code: Data Flow Through Chained Calls

Week 7

Draw two nested calls so the value handed from the inner function to the outer one is visible on the chart.

Assignment

3.2.19 Lab: Compose Two Functions

Week 7

Write two returning functions, then feed one result into the other and log the chain. Auto-graded.

Reading

3.2.20 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.21 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.22 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.23 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.24 Parameters and Return Values

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

→ View full module page
3.3Arrays
Slides

3.3.1 Slides: Arrays

Arrays slides. Placeholder until the deck is built from the book.

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 one value inside an array by its index to update a score in place. Auto-graded.

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.

Reading

3.3.6 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.7 Lab: Front-of-Line Queue

Week 8

Use push and shift to move people through a queue, first in first out. Auto-graded.

Reading

3.3.8 Reading: Splitting Text into Lines (.split)

Week 8

Learn how .split() turns one big string into an array of lines: the same pattern used when reading a text file. Read before the file-processing exercises.

Assignment

3.3.9 Sum an Array

Week 8

Use a for loop and .length to add up all numbers in an array, then log the total. Auto-graded.

Worked Example

3.3.10 Worked Example: A tiny menu loop

Week 8
Flowchart

3.3.11 Chart the Code: Looping Over an Array

Draw the menu loop with the hexagon, and get the arrow that leaves the loop pointing at the right place.

Reading

3.3.12 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.

Worked Example

3.3.13 Worked Example: Keeping Only the Passing Scores

Week 8
Assignment

3.3.14 Lab: Write a Function That Returns a New Array

Week 8

Write a function that builds and returns a new array of transformed values, proving the original is untouched. Auto-graded.

Reading

3.3.15 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.16 Worked Example: A Tic-Tac-Toe Board as a Nested Array

Week 8
Assignment

3.3.17 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.

Assignment

3.3.18 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

Function Expressions and Arrow Functions slides. Placeholder until the deck is built from the book.

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.

Flowchart

3.4.9 Chart the Code: Expanding an Arrow to Its Full Form

Week 8

Expand a one-line arrow into the steps it actually runs: read the parameters, call the callback, decide whether it has run twice, and print the result.

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.

Flowchart

3.4.15 Chart the Code: Decision Tree for Form Choice

Week 8

Chart the rule for choosing between a declaration, an expression, and an arrow: is it a main operation or a short helper, and how many parameters does it take?

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.

Flowchart

3.4.20 Chart the Code: Full Syntax-Forms Comparison

Week 8

Chart one operation walking through all three function forms, so the piece each form adds or drops — name, return, parens — is visible side by side.

Assignment

3.4.21 Lab: Parameters, Return Values, and Arrow Syntax

Week 8

Group code into reusable logic blocks with parameters and return values.

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

Objects and Properties slides. Placeholder until the deck is built from the book.

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
Flowchart

3.5.11 Chart the Code: Tracing a Nested Access

Week 8

Chart a loop that reads a nested field inside an array, then a decision on a nested value. Get the loop's arrows landing in the right place.

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
Flowchart

3.5.21 Chart the Code: Destructuring vs. Plain Access

Week 8

Chart a function whose body destructures its parameter, and see the unpack as its own task before the work that uses it.

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, options objects, and destructuring. Checked instantly.

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

3.6.1 Slides: Pass by Value/Reference

Week 7

Pass by Value/Reference slides. Placeholder until the deck is built from the book.

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
Flowchart

3.6.7 Chart the Code: Reassignment vs. Mutation Trace

Week 7

Trace a function that mutates an array and then reassigns it, and chart which write the caller can see.

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 6.2 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

Array Methods slides. Placeholder until the deck is built from the book.

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.

Flowchart

3.7.5 Chart the Code: `.map()`'s Callback Trace

Week 9

Draw what .map() does to each element: an implicit loop, one callback call per item, and the collected results. Get the loop-back arrow right.

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
Flowchart

3.7.16 Chart the Code: Spread vs. Rest, Side by Side

Week 9

Draw the two directions the three dots can point: a definition that gathers arguments into an array, and a call that unpacks an array into arguments.

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 Method Sort 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

Saving and Loading Data slides. Placeholder until the deck is built from the book.

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
Flowchart

3.8.17 Chart the Code: Save/Load Round Trip End to End

Week 10

Draw the whole save-and-load pattern: stringify to save, read the key, decide whether anything was stored, parse inside a try, and fall back to defaults. Get both decision exits right.

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 so it survives the page closing. 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

Eight 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 Synthesis1 module
Chapter 5moshion — Game Development Foundations4 modules
5.1Hello Sprite and Movement
Slides

5.1.1 Slides: moSHion Foundations

Hello Sprite and Movement slides: canvas, sprites, keyboard input, and the frame loop. Placeholder until the deck is rebuilt from bookSHelf.

Video

5.1.2 Video: Your first moSHion sketch

Week 10

5-min walkthrough introducing canvas, sprite, and run cycle. 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.5 (Canvas).

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 Lab: Drop one sprite, change its color

Week 10

Practice from 5.1.6: create a canvas, drop a single sprite at the centre, and set its color. Three steps, no movement yet.

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.4 (worked example).

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

3-min walkthrough of the setup/draw frame loop at 60 fps. Watch after Hello Sprite, before Make it Move.

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.15 (Velocity).

Worked Example

5.1.14 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.

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. 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.

moSHion Lesson

5.1.18 Lab: Delete the else, watch drift

Week 10

Start from a working WASD movement pattern, delete the two else lines, observe drift, then restore them.

Reading

5.1.19 Reading: WASD-not-arrows

Week 10

Why graded labs use 'a'/'d'/'w'/'s' instead of arrow keys, and how to swap them into the movement pattern. Read after 5.1.18.

moSHion Lesson

5.1.20 Make it Move

Week 10

Drive a sprite with the arrow keys by setting vel.x and vel.y based on what's pressed.

Assignment

5.1.21 Sprite Playground

Week 10

Build a sprite playground combining canvas, WASD-controlled sprite, auto-motion, and on-screen text. Auto-graded.

Assignment

5.1.22 Frame Loop Writeup

Week 10

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

Challenge

5.1.23 Challenges

Week 10

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

Worked Example

5.1.24 Falling Block: Example

Week 10

A dynamic block falls under gravity and lands on a static floor. Read the example, then experiment.

→ View full module page
5.2Physics Feel
Slides

5.2.1 Slides: Physics Feel

Week 15

Gravity, ground-gated actions, bounciness and friction, forces, and cleanup slides. Placeholder until the deck is rebuilt from bookSHelf.

Reading

5.2.2 Reading: Gravity

Week 15

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

moSHion Lesson

5.2.3 Lab: Tune Gravity

Week 15

Try different world.gravity.y values on the same scene and describe how each one feels. Non-graded: discuss with a partner.

Reading

5.2.4 Reading: Ground-Gated Actions

Week 15

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

moSHion Lesson

5.2.5 Lab: Add a Jump

Week 15

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

Reading

5.2.6 Reading: Bounciness and Friction

Week 15

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

moSHion Lesson

5.2.7 Bouncy Ball

Week 15

Learn how bounciness and friction change how sprites feel.

Reading

5.2.8 Reading: Forces vs Velocity

Week 15

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

moSHion Lesson

5.2.9 Lab: Wind Zone

Week 15

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

Reading

5.2.10 Reading: Cleanup and Delete

Week 15

delete() vs .visible. Read before 5.2.11 Lab: Reaching the Goal.

moSHion Lesson

5.2.11 Lab: Reaching the Goal

Week 15

A single-fire win check with delete(). Auto-graded.

Worked Example

5.2.12 Worked Example: The Finished Scene

Week 15
Assignment

5.2.13 Pinball Scene

Week 15

Build a pinball-style scene: static obstacles, a bouncy ball, gravity, and a reset key. Auto-graded.

Assignment

5.2.14 Vel vs applyForce

Week 15

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

Challenge

5.2.15 Challenges: Optional Stretch

Week 15

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

→ View full module page
5.3Classes and Instances
Slides

5.3.1 Slides: Object-Oriented Programming

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

Video

5.3.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

5.3.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 5.3.4.

Reading

5.3.4 Reading: The new operator

Week 12

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

Reading

5.3.5 Reading: constructor and its parameters

Week 12

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

Worked Example

5.3.6 Worked Example: You've been using classes

Week 12
Reading

5.3.7 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

5.3.8 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

5.3.9 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

5.3.10 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

5.3.11 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

5.3.12 Worked Example: this is a pronoun

Week 12
moSHion Lesson

5.3.13 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 5.3.6 / 5.3.12 worked examples and the 5.4.10 Enemy class worked example.

Worked Example

5.3.14 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.

Video

5.3.15 Video: The this keyword

Week 12

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.

→ View full module page
5.4Writing Your Own Classes
Reading

5.4.1 Reading: Methods: functions that live on a class

Week 12

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

moSHion Lesson

5.4.2 Lab: Method with no params

Week 12

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

moSHion Lesson

5.4.3 Lab: Method with parameters

Week 12

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

5.4.4 Lab: Method that returns a value

Week 12

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

moSHion Lesson

5.4.5 Lab: A method calling this.otherMethod()

Week 12

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

Flowchart

5.4.6 Chart the Code: A Method That Calls a Method

Draw a method calling another method. Two double-rails, and flow that comes back from both.

Reading

5.4.7 Reading: Why this.sprite, not extends Sprite

Week 12

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

moSHion Lesson

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

Week 12

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

moSHion Lesson

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

Week 12

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

Worked Example

5.4.10 Worked Example: Write an Enemy class (integration)

Week 12
moSHion Lesson

5.4.11 Lab: Three Enemies in three variables

Week 12

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

moSHion Lesson

5.4.12 Lab: An array of Enemies

Week 12

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

5.4.13 Lab: Loop over an array of instances

Week 12

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

5.4.14 Reading: Parallel Arrays vs Classes

Week 12

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

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

Week 12
Reading

5.4.16 Read the Charts: Three Variables or Three Objects

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

Reading

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

Week 12

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

Assignment

5.4.18 Collectible Class

Week 12

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

5.4.19 Procedural vs OOP Writeup

Week 12

Comparison of procedural and object-oriented programming.

Reading

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

Week 12

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

Challenge

5.4.21 Challenges

Week 12

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
Chapter 6moshion — Game Mechanics8 modules
6.1Groups
6.2Overlaps and Collisions
6.3Physics Applications
6.4Animated Sprites and Camera
Slides

6.4.1 Slides: Animation & Camera

Animated Sprites and Camera slides: addAni / changeAni, camera follow, smoothing with lerp, and layer for render order. Placeholder until the deck is rebuilt from bookSHelf.

Video

6.4.2 Video: Animating a sprite in moshion

Week 15

How addAni registers named animations and changeAni swaps the active one: driven by player state (idle vs run). Watch before 6.4.9 Animated Sprites Sandbox.

Reading

6.4.3 Reading: moSHion docs: Animation

Week 15

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

Reading

6.4.4 Reading: addAni(name, frames)

Week 15

How sprite.addAni(name, frame1, ...) registers a named animation and makes it the active default. Read before 6.4.5 (changeAni).

Reading

6.4.5 Reading: changeAni(name)

Week 15

How sprite.changeAni(name) swaps the active animation between previously registered names. Read before 6.4.8 (Worked Example).

Reading

6.4.6 Reading: frameDelay (cycle speed)

Week 15

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

Reading

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

Week 15

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

Worked Example

6.4.8 Worked Example: Animating a Sprite

Week 15
moSHion Lesson

6.4.9 Animated Sprites Sandbox

Week 15

Drive a sprite's visual from input state: the same swap pattern used by addAni / changeAni, with sprite.image swapping as the asset-free placeholder. Idle when standing, run when moving, jump when 'w' is held.

Video

6.4.10 Video: Camera follow explained with a flashlight

Week 15

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

Reading

6.4.11 Reading: moSHion docs: Camera

Week 15

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

Reading

6.4.12 Reading: camera.x / camera.y

Week 15

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

Reading

6.4.13 Reading: Camera-follow pattern

Week 15

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

Reading

6.4.14 Reading: Smoothing with lerp

Week 15

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

Reading

6.4.15 Reading: sprite.layer (render order)

Week 15

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

Worked Example

6.4.16 Worked Example: Camera Follow

Week 15
Worked Example

6.4.17 Worked Example: Smooth Camera with lerp

Week 15
Assignment

6.4.18 Side-Scrolling Platformer

Week 15

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.4.19 Challenges

Week 15

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.5Save and Load
Slides

6.5.1 Slides: Your Game Forgets: The Problem

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.5.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.5.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.5.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.5.5 Reading: getItem: Load Saved Data

Week 16

How getItem(key) reads back a value your game saved earlier. Covers the basics of retrieving save data: the string type gotcha is in 6.5.6.

Reading

6.5.6 Reading: getItem Returns a String

Week 16

getItem always gives you a string, even when you stored a number. String comparisons give wrong results: here's the Number() fix and the || 0 fallback.

Worked Example

6.5.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.5.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.5.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.5.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.5.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.5.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.5.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.5.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.5.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.5.16 Reading: moSHion docs: removeItem and clearStorage

Week 16

removeItem(key) deletes one saved key. clearStorage() wipes everything. When and how to use each.

Worked Example

6.5.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.5.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.5.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.5.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.5.21 Read the Chart: Does Continue Show Up?

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

Worked Example

6.5.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.5.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.5.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.5.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.5.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.5.27 Challenges: Extended Save Features

Week 16

Extend your save system: save file previews (show slot contents before loading), save timestamps, multiple profiles, or a 'delete all saves' with double-confirmation.

→ View full module page
6.6Game State Machines
Slides

6.6.1 Slides: One Game, Many Screens

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.6.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.6.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.6.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.6.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.6.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.6.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.6.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.6.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.6.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.6.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.6.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.6.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.

Flowchart

6.6.14 Chart the Code: The Three-State Machine

Draw the title / play / gameover machine. This is the chart that pays for itself: a state machine is far easier to argue about as a picture than as a switch.

Reading

6.6.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.6.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.6.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.6.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.6.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.6.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.

Flowchart

6.6.21 Fix the Broken Chart: the Pause State

Someone half-wired a pause feature and the chart shows it. Find what the red checks are pointing at and repair it.

Worked Example

6.6.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.6.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.6.24 Worked Example: Save on State Transition

Week 17
Worked Example

6.6.25 Worked Example: Continue Loads the Correct State

Week 17
Assignment

6.6.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.6.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.6.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.7Advanced Input
Slides

6.7.1 Slides: Advanced Mechanics: One Last Toolkit

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.8. Placeholder until the deck is rebuilt from bookSHelf.

Video

6.7.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.7.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.7.4 Reading: moSHion docs: mouse.pressing()

Week 17

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

Reading

6.7.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.7.4 to see how one-shot input differs from held input.

Reading

6.7.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.7.7 Worked Example: Click to Spawn a Sprite

Week 17
Video

6.7.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.7.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.7.10 Worked Example: Drag a Sprite Around

Week 17
Flowchart

6.7.11 Fix the Broken Chart: Dragging a Sprite

Someone charted the grab half of drag-and-drop and never charted the letting go. Find what the red checks are pointing at.

Video

6.7.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.7.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.7.16 Worked Example: Two Paddles, Two Schemes.

Reading

6.7.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.7.15 Worked Example: Bounciness Comparison.

Worked Example

6.7.15 Worked Example: Bounciness Comparison

Week 17
Worked Example

6.7.16 Worked Example: Two Paddles, Two Schemes

Week 17
→ View full module page
6.8Joints
Video

6.8.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.8.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.8.3 Worked Example: Pendulum with DistanceJoint

Week 17
Reading

6.8.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.8.5 Worked Example: Rotating Arm with HingeJoint

Week 17
Reading

6.8.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.8.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.8.9 Worked Example: Launch a Sprite with applyForce.

Reading

6.8.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.8.9 Worked Example: Launch a Sprite with applyForce.

Worked Example

6.8.9 Worked Example: Launch a Sprite with applyForce

Week 17
Video

6.8.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.8.11 Worked Example: Slingshot End-to-End

Week 17
Flowchart

6.8.12 Chart the Code: The Slingshot

Chart the three-stage slingshot: aim, stretch, release. The stage nobody draws is the one where nothing is happening yet.

Challenge

6.8.13 Challenges: SliderJoint, Trebuchet, Swinging Rope

Week 17

Three optional stretch prompts for Unit 6.8: 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.8.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.8.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.7 and 6.8 and previews what Unit 7.1 asks you to do: design and pitch your own game from scratch.

→ View full module page
Chapter 7Q2 Synthesis — Game Capstone1 module
Chapter 81 module

Report an issue

or paste one — optional, max 2 MB

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