shCode

Choose a lesson

Chapter 1JavaScript Fundamentals5 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 Naming Style

Write variable names in camelCase 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.

Assignment

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
Chapter 2Control Flow5 modules
2.1Conditionals
Slides

2.1.1 Slides — Conditionals

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

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

Assignment

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.

Assignment

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.

Assignment

2.1.7 Add an else

Week 5

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

Assignment

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

Assignment

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

Assignment

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

Assignment

2.1.17 Predict, Then Run

Week 5

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

Reading

2.1.18 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 the ternary operator lessons.

Reading

2.1.19 Reading — The Conditional Operator ?

Week 5

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

Worked Example

2.1.20 Worked Example — Ticket Price with ?

Week 5

Assignment

2.1.21 Write Your First Ternary

Week 5

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

Reading

2.1.22 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.23 Worked Example — Size Label with Chained ?

Week 5

Assignment

2.1.24 Chain Your Ternaries

Week 5

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

Reading

2.1.25 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.26 Worked Example — Rewriting a Misused Ternary

Week 5

Assignment

2.1.27 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.28 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.29 Worked Example — Combining conditions

Week 5

Assignment

2.1.30 Guard with &&

Week 5

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

Assignment

2.1.31 Branch with ||

Week 5

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

Assignment

2.1.32 Flip It with !

Week 5

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

Worked Example

2.1.33 Worked Example — The OR String-Literal Trap

Week 5

Assignment

2.1.34 Debug the Door

Week 5

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

Assignment

2.1.35 Combine &&, ||, and !

Week 5

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

Assignment

2.1.36 Predict the Chain

Week 5

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

Assignment

2.1.37 Print Settings Advisor

Week 5

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

Assignment

2.1.38 Challenges — Optional Stretch

Week 5

Optional stretch problems. Auto-graded.

Assignment

2.1.39 Grade Recommendation Advisor

Week 5

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

Quiz

2.1.40 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

Assignment

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

Assignment

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.

Assignment

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 — while & do…while

Week 6

while checks the condition before each run; do…while runs once first. Learn both, 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

Assignment

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.

Assignment

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.

Reading

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

Assignment

2.2.20 Challenges — Optional Stretch

Week 6

Optional stretch problems. 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

Assignment

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.

Assignment

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.

Assignment

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

Assignment

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.

Assignment

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

Assignment

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.

Assignment

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

Assignment

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

Assignment

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.

Assignment

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.

Assignment

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.

Assignment

2.3.31 Challenges — Optional Stretch

Week 6

Optional stretch problems. 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

Assignment

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

Assignment

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.

Assignment

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

Assignment

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.

Assignment

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

Assignment

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

Assignment

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

Assignment

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

Assignment

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.

Assignment

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.

Assignment

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.

Assignment

2.4.33 Challenges — Optional Stretch

Week 7

Optional stretch problems. 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?.

Assignment

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

Assignment

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.

Assignment

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.

Assignment

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.

Assignment

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.

Assignment

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

Assignment

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

Assignment

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.

Assignment

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.

Assignment

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

Assignment

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.

Assignment

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.

Assignment

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.

Assignment

2.5.27 Challenges — Optional Stretch

Week 7

Optional stretch problems. Auto-graded.

→ View full module page
Chapter 3Functions and Data4 modules
3.1Functions: Definition and Calls
3.2Parameters and Return Values
3.3Arrays
3.6Functions: Pass by Value/Reference
Chapter 4Q1 Synthesis1 module
Chapter 5shplay — Game Development Foundations4 modules
5.1Hello Sprite and Movement
Slides

5.1.1 Slides — shplay 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 shplay 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 shplay calls setup() once and draw() every frame. Read before 2.1.3a (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 2.1.3b (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 2.1.3c (lab).

shPlay Lesson

5.1.7 Lab — Drop one sprite, change its color

Week 10

Practice from 2.1.3b: 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 2.1.3e.

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

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

shPlay Lesson

5.1.11 Hello Sprite

Week 10

Your first shplay 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 2.1.7a (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 2.1.7.

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

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

shPlay 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 2.1.7d.

shPlay 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
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 shplay 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 2.2.3a.

Reading

5.3.4 Reading — The new operator

Week 12

What new does mechanically: allocate, run constructor, return. Read right after 2.2.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 2.2.3a.

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.

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

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

shPlay 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

shPlay 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 2.2.4 / 2.2.5 worked examples and the 2.2.8 Enemy class lab.

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.

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

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

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

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

Assignment

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.

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

shPlay 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

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

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

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

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 6shplay — 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 shplay

Week 15

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

Reading

6.4.3 Reading — shplay docs: Animation

Week 15

shplay docs chapter on Animation. Read before 2.4.5 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 2.4.3b (changeAni).

Reading

6.4.5 Reading — changeAni(name)

Week 15

How sprite.changeAni(name) swaps the active animation between previously registered names. Read before 2.4.4 (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 2.4.5 (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 2.4.5 (Animated Sprites Sandbox).

Worked Example

6.4.8 Worked Example — Animating a Sprite

Week 15

shPlay 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 2.4.8 Worked Example — Camera Follow.

Reading

6.4.11 Reading — shplay docs: Camera

Week 15

shplay docs chapter on Camera. Read before 2.4.8 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 2.4.7b (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 2.4.8 (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 2.4.9 (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 2.4.10 (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 2.5.5a.

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 — shplay 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 — shplay 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 — shplay 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 — shplay 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 — shplay 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 — shplay docs: switch in draw()

Week 17

In shplay 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 — shplay 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.

Assignment

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

Assignment

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 and Joints opening slides — the three big ideas before capstone: mouse input, joints, and the slingshot pattern. Everything in this unit feeds directly into A17.1 and your capstone design. 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 — shplay 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 — shplay docs: mouse.pressing()

Week 17

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

Reading

6.7.5 Reading — shplay docs: mouse.presses()

Week 17

mouse.presses() is true on exactly one frame — the moment the button first goes down. Read this after 2.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

Assignment

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.

Reading

6.7.12 Reading — shplay 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 2.7.19 Worked Example — Launch a Sprite with applyForce.

Reading

6.7.13 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 2.7.19 Worked Example — Launch a Sprite with applyForce.

Worked Example

6.7.14 Worked Example — Launch a Sprite with applyForce

Week 17

Video

6.7.15 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.7.16 Worked Example — Slingshot End-to-End

Week 17

Assignment

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

Video

6.7.18 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.19 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 2.7.25 Worked Example — Two Paddles, Two Schemes.

Reading

6.7.20 Reading — shplay 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 2.7.24a Worked Example — Bounciness Comparison.

Worked Example

6.7.21 Worked Example — Bounciness Comparison

Week 17

Worked Example

6.7.22 Worked Example — Two Paddles, Two Schemes

Week 17

Assignment

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

Challenge

6.7.24 Challenges — SliderJoint, Trebuchet, Swinging Rope

Week 17

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

Video

6.7.25 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 Unit 2.7 and previews what Unit 2.8 asks you to do: design and pitch your own game from scratch.

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