This course is for programmers who know Python well. It covers only what JavaScript’s loops do differently. Your project is a night-bus team’s morning report, a Python script you’ll port to JavaScript. Its first loop prints last night’s delays:
delays = [4, 0, 12]
for delay in delays:
print(delay)
Here’s a JavaScript port that still says in, like Python, as plenty of code online does:
const delays = [4, 0, 12];
for (const delay in delays) {
console.log(delay);
}
It runs without an error and prints this:
0
1
2
Python prints 4, 0, and 12, but the JavaScript port prints 0, 1, and 2. Why? And what should you write instead? This course answers both: loops are where Python habits often fail silently.
The team’s script starts with that loop. Its report has four parts: the late departures, the delay totals per route, the first canceled trip, and the route supervisors. The team is moving its tools to JavaScript, so you’ll port the script 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 fromfor...in - Count without
range(), with the classicforloop - Loop until something happens, and search without
for...else - Loop over positions, pairs, objects, and Maps without
enumerate(),zip(), or.items() - Port the whole night-bus report to JavaScript
You should know Python’s loops, including enumerate(), zip(), and looping over a dictionary, and the JavaScript basics: const and let, functions and arrow functions, arrays and objects. You’ll also need a current version of Node.js and a project set up for ES modules (ECMAScript modules), with "type": "module" in its package.json. The examples use Node 26 and Python 3.15.
Short videos mix with text lessons and exercises, and every video has a summary below it. A quiz and a summary close the course.
Up next: Looping Over Items With for…of, which starts with this same loop.