In JavaScript, the plain object does the everyday work of Python’s dict, all the way to JSON, and a Set does the work of a set. Your project is to port the label script for Marta’s notebook shop.
Here’s a first taste, with order 1042’s insured value. Iris chose no cover, so the value is 0.
This Python code reads it with .get() and a default of 50, which is only for orders without
the key:
order = {"id": 1042, "insured_value": 0}
insured = order.get("insured_value", 50)
print(f"Insured value: £{insured}")
Python keeps the 0:
Insured value: £0
JavaScript objects have no .get(), so the port a Pythonista reaches for uses || instead:
const order = { id: 1042, insured_value: 0 };
const insured = order.insured_value || 50;
console.log(`Insured value: £${insured}`);
It runs with no error and prints this:
Insured value: £50
With || in place of .get()’s default, Iris’s 0 came out as 50: cover she turned down. Ports like
this can run without an error and give a different answer, and this course shows you where, and
what JavaScript does instead.
Marta sells hand-bound notebooks and packs every order herself. Her Python script,
shipping_label.py, picks the address, looks up the postage, tidies the tags, and prints the label
as JSON. You’ll port it to JavaScript.
By the end of this course, you’ll be able to:
- Write an order as an object literal, read it with a dot or brackets, and list its keys and entries
- Fill in defaults with
??and reach into nested data that may be missing with?. - Drop repeated tags with a Set, and spot remote postcodes with string keys
- Read pasted JSON with
JSON.parse()and print the label withJSON.stringify() - Put Marta’s whole label script together in JavaScript
You only need to know Python’s dicts, sets, and json module as you use them every day: get(),
keys(), items(), in, json.loads(), and json.dumps(). In JavaScript, you only need to
know how to write a small program with const, if, template literals, and arrays.
A current version of Node and of Python is fine: 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. A project puts the whole label script together, and a quiz and a summary close the course.
Next up: Reading an Order as an Object, where order 1042 goes from a Python dict to a JavaScript object literal.