This course is about copying, freezing and sorting data the JavaScript way. Your project is to port the league table script of Nadia, volunteer secretary of the Eastgate Leisure Centre’s Thursday-night five-a-side league.
Here’s a first taste. Nadia’s Python script keeps the week’s results provisional in a deep copy, not the confirmed table, then prints each team’s move. Here’s the copy step, with the rest of the script folded:
import copy
# POINTS, table, RESULTS and the helpers
provisional = copy.deepcopy(table)
for home, home_goals, away, away_goals in RESULTS:
...
# print the table, each move and the leaders
Python prints two teams up one place and two down one, and the confirmed leaders are still Athletic:
Week 9 table (provisional)
1. Rovers 16 pts, form LDWLW, up 1
2. Athletic 16 pts, form WDWWD, down 1
3. Dynamo 13 pts, form LWDLW, up 1
4. Wanderers 13 pts, form DLWWD, down 1
5. United 9 pts, form WLLWL, same
6. Albion 7 pts, form LDWLL, same
Confirmed leaders: Athletic
Here’s the JavaScript port of the same step, line for line, with the copy made with spread:
// POINTS, table, RESULTS and the helpers
const provisional = [...table];
for (const match of RESULTS) {
// ...
}
// print the table, each move and the leaders
It runs with no error and prints this:
Week 9 table (provisional)
1. Rovers 16 pts, form LDWLW, same
2. Athletic 16 pts, form WDWWD, same
3. Dynamo 13 pts, form LWDLW, same
4. Wanderers 13 pts, form DLWWD, same
5. United 9 pts, form WLLWL, same
6. Albion 7 pts, form LDWLL, same
Confirmed leaders: Rovers
Every move says same, and the confirmed leaders are Rovers, where Python says Athletic. 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.
Six teams play each Thursday, and the league committee confirms each week’s results. The center’s booking site runs on Node, so you’ll port Nadia’s script.
By the end of this course, you’ll be able to:
- Copy arrays, records, Maps and Sets where Python uses
table.copy()and{**rovers}, and make a copy that really is separate from its original - Make tuple-like data read-only with
Object.freeze() - Sort records with compare functions where Python passes
key=, and rank teams that are level on points - Change a copy, not the original, with
with(),toSpliced()andtoSorted() - Put Nadia’s whole script together in JavaScript
You only need to know Python’s copies, tuples and sort keys: shallow and deep
copies, tuples as records that can’t change, and sorting with a key function. In JavaScript, you
only need to know how to write small programs with arrays of objects, functions and arrow
functions, copy an array with slice(), sort numbers with a compare function, and use Map and
Set.
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, so you can review without rewatching. A project puts Nadia’s whole script together, and a quiz and a summary close the course.
Next up: Copying Arrays and Records With Spread, where you copy the confirmed table and Rovers’ record the JavaScript way, and copy Maps and Sets with their own constructors.