Loading video player…

Welcome to the Race Results Cleaner

Welcome to the Race Results Cleaner

JavaScript has no comprehensions. Array methods that take a function do their job, and three dots do the work of the star and the double star. The ports look close, and most slips give a wrong answer, not an error. Along the way, you’ll port a half marathon timing desk’s results script.

Here’s a first taste. A Python comprehension, [r["name"] for r in runners if r["finish"] != "DNF"], lists the name of every runner whose finish isn’t DNF (did not finish) and prints six:

Language: Program Output
['Ana Ruiz', 'Tom Okafor', 'Mei Chen', 'Priya Nair', 'Sam Kowalski', 'Jo Lindqvist']

Ported in the order it reads, runners.map((r) => r.name).filter((r) => r.finish !== "DNF"), the JavaScript runs without an error, and logs seven names:

Language: Program Output
[
  'Ana Ruiz',
  'Tom Okafor',
  'Mei Chen',
  'Lars Berg',
  'Priya Nair',
  'Sam Kowalski',
  'Jo Lindqvist'
]

One of them is Lars Berg, who didn’t finish.

At a half marathon, the timing company exports each runner’s chip reads as text rows, some messy: a stray space, a missing read, a DNF. The desk’s Python script cleans them and prints a report: the finishers with a missing read, the average finish, and the fastest runner in each age group. The live results page is moving to JavaScript, and that port would list a runner who dropped out.

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

  • Turn comprehensions into array method chains, objects and sets
  • Unpack arrays and objects, and spread them where Python uses * and **
  • Ask about a whole array, total it, and find the fastest
  • Port the whole results cleaner to JavaScript

You need to know Python’s comprehensions, map(), any(), all(), sum(), min() with key=, and * and ** unpacking. In JavaScript, you need to know arrays and objects, arrow functions, for...of loops and array destructuring. Any current version of Node and Python will do: the examples use Node 26 and Python 3.15.

The course mixes videos with text lessons and exercises, and every video has a summary below it. A quiz and a summary close the course.

Up next is the video Filtering and Transforming With filter() and map(), where you’ll see why Lars Berg got through.

Download

Sample Code (.zip)

19.3 KB
Download

Course Slides (.pdf)

854.1 KB

Become a Member to join the conversation.