Loading video player…

Welcome to the Garden Season Report

This course is about Maps, Sets and objects, and when to use each. Your project is to port Rosa’s season report for the Brook Street Community Garden.

Here’s a first taste. Plot 3 goes to the first person on the garden’s waiting list, which is kept in the order people asked. Here’s that step in Rosa’s Python script:

Language: Python
waiting = {214: "Dev Patel", 187: "Hannah Cole",
           305: "Marek Nowak", 42: "June Harris"}
member = next(iter(waiting))
name = waiting[member]
print(f"Plot 3 goes to {name} (member {member})")

Dev Patel asked first, and Python gives him the plot:

Language: Program Output
Plot 3 goes to Dev Patel (member 214)

Here’s the JavaScript port, line for line, with the waiting list kept in an object:

Language: JavaScript
const waiting = { 214: "Dev Patel", 187: "Hannah Cole",
  305: "Marek Nowak", 42: "June Harris" };
const member = Object.keys(waiting)[0];
const name = waiting[member];
console.log(`Plot 3 goes to ${name} (member ${member})`);

It runs with no error and prints this:

Language: Program Output
Plot 3 goes to June Harris (member 42)

June Harris, member 42, gets the plot, where Python says Dev Patel, member 214, and she asked last. A line-for-line port can run without an error and quietly give a different answer, and this course shows you where, and what JavaScript does instead.

Rosa coordinates the garden’s nine plots. Its booking page runs on Node, so you’ll port her script.

By the end of this course, you’ll be able to:

  • Choose between a Map and a plain object, and update and check a Map with set(), delete() and has() where Python assigns to a key, calls pop() and uses in
  • Count and group without Counter or defaultdict, with a Map and Object.groupBy()
  • Combine and compare Sets with union(), intersection(), difference() and isSubsetOf() where Python uses |, &, - and <=
  • Build and deep-copy nested Maps and Sets with getOrInsert() and structuredClone(), where Python uses defaultdict(set) and copy.deepcopy()
  • Put Rosa’s whole season report together in JavaScript

You only need to know Python’s dicts, sets, Counter and defaultdict. In JavaScript, you only need to know how to work with objects and arrays of objects, read an object’s keys with Object.keys() and Object.entries(), use Sets and arrow functions, give a default with ??, copy objects and arrays with structuredClone(), and sort with a compare function.

A few methods in this course are recent, such as Object.groupBy(), the Set methods like union(), and getOrInsert(). The examples use Node 26 and Python 3.15.

The course mixes short videos and text lessons, with exercises where you write the code yourself. Every video has notes below it, so you can review without rewatching. A quiz and a summary close the course.

Next up: Keeping the Waiting List in Order, which starts from Rosa’s waiting list as a Python dict and ports it to JavaScript so that the right person gets the plot.

Download

Sample Code (.zip)

14.2 KB
Download

Course Slides (.pdf)

826.2 KB

00:00 Welcome to JavaScript Map and Set for Pythonistas! This course is about Maps, Sets and objects, and when to use each. Your project: port Rosa’s season report for a community garden, with its nine plots and a waiting list of members kept by member number.

00:18 Here’s a first taste. Plot 3 goes to the first person on Rosa’s waiting list, kept in the order people asked. Python prints Dev Patel. The JavaScript port keeps the list in an object and prints this.

00:36 June Harris, member 42, gets the plot, where Python says Dev Patel, member 214. She asked last. A line-for-line port can run without an error and quietly give a different answer.

00:52 This course shows you where, and what JavaScript does instead.

00:58 Rosa coordinates the garden’s nine plots. Its booking page runs on Node, so you’ll port her script.

01:07 By the end, you’ll choose between Maps and objects, count and group, combine Sets, and nest Maps and Sets. Then the project ports Rosa’s whole script.

01:20 You only need to know Python’s dicts, sets, Counter and defaultdict, and enough JavaScript for objects and their keys, Sets, arrow functions, deep copies, defaults and compare functions.

01:33 The examples use Node 26 and Python 3.15, and a few methods are recent.

01:41 Short videos mix with text lessons and exercises, and every video has notes below it. A quiz and a summary close the course. Next up is Keeping the Waiting List in Order, a text lesson that starts from Rosa’s waiting list as a Python dict.

Become a Member to join the conversation.