Loading video player…

Welcome to the Night-Bus Report

JavaScript’s loops look familiar to a Python programmer, and that’s the trouble: loops are where Python habits trip you up, often without an error. Port Python’s for delay in delays: to JavaScript, keep the word in, and JavaScript prints the positions 0, 1, and 2 instead of the delays.

In this course, you’ll port a night-bus operations team’s morning report from Python to JavaScript, one loop at a time.

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

  • Loop over items with for...of, and tell it apart from for...in
  • Count without range() using the classic for loop
  • Loop with while and do...while, and search without for...else
  • Loop over positions, pairs, objects, and Maps
  • Spot a Python habit in a JavaScript loop, whether you or an AI assistant wrote it

You’ll need Python loops, enumerate(), zip(), and looping over a dictionary, plus Node 26 and the JavaScript basics: const and let, arrays, and objects. The Python examples use Python 3.15.

Next up: Looping Over Items With for…of, where you port the report’s first loop.

Download

Sample Code (.zip)

11.4 KB
Download

Course Slides (.pdf)

605.5 KB

00:00 Welcome to JavaScript Loops for Pythonistas! This course is for programmers who know Python well, and it covers only what JavaScript’s loops do differently.

00:10 Your project is a night-bus team’s morning report on last night’s bus delays, a Python script you’ll port to JavaScript. Here’s a first taste.

00:21 This Python loop prints last night’s bus delays. Here’s a JavaScript port that still says in, like Python, as plenty of code online does. Node prints zero, one, two.

00:36 No error, and those aren’t the delays. Why? And what should you write instead? Loops are where Python habits trip you up in JavaScript, often silently. This course is about them.

00:55 Every morning, a night-bus team runs a script that starts with this loop. It prints a report: late departures, delay totals per route, the first canceled trip, and route supervisors.

01:08 The team is moving to Node, and you’ll port the script one loop at a time.

01:14 By the end, you’ll write each of these loops the JavaScript way. You’ll loop over items and count without range. You’ll loop until something happens, and over pairs without enumerate or zip.

01:28 Then the project puts it all together.

01:32 You’ll need the Python loops you know, with enumerate, zip, and dicts. For JavaScript, you’ll need Node 26, a project set up for ES modules, and the basics: const and let, arrays, and objects.

01:48 Short videos like this one mix with text lessons and exercises, and every video has a summary below it. A quiz and a summary close the course. The next video, Looping Over Items With for…of, starts with this same loop.

Become a Member to join the conversation.