In JavaScript, one ordered collection, the array, does the work of Python’s lists, and often of
its tuples, and its methods take over from Python’s slicing, del, remove(), and sorted().
Your project is to port a support team’s Python script that decides who carries the pager each
week.
Here’s a first taste, with the pager’s numbers: how many times it went off each week over the last eight weeks. This Python code sorts them smallest first:
pages = [3, 9, 0, 14, 2, 7, 4, 11]
pages.sort()
print(pages)
Python prints the counts in order:
[0, 2, 3, 4, 7, 9, 11, 14]
Here’s the JavaScript port, line for line:
const pages = [3, 9, 0, 14, 2, 7, 4, 11];
pages.sort();
console.log(pages);
It runs with no error and prints this:
[
0, 11, 14, 2,
3, 4, 7, 9
]
Look at 11 and 14: they come before 2. Why? Line-for-line ports like this one can quietly
give a different answer, and this course shows you where, and what JavaScript does instead.
The team handles customer support for a software company and shares one pager: each week, one person carries it out of hours. Every Monday, the team lead runs a short Python script that rotates the rota, handles leave and new hires, and reports how often the pager went off. You’ll port it to JavaScript, one list job at a time.
By the end of this course, you’ll be able to:
- Build the rota as an array and read it with
rota[0],rota.at(-1), and.length, where Python usesrota[-1]andlen() - Add and remove at the ends with
.push(),.pop(),.shift(), and.unshift() - Hold a pair like the out-of-hours window in an array or an object, where Python uses a tuple
- Take copies with
.slice(),.toReversed(), and.concat() - Change an array in place with
.splice(), where Python usesdelandinsert() - Search an array with
.includes()and.indexOf(), and check for-1before you splice - Sort a copy with
.toSorted(), passing a compare function for numbers - Port a short Python script that rotates, slices, edits, searches, and sorts a list to JavaScript
You only need to know Python’s lists as you use them every day: indexing, slicing, len(),
in, sorted(), and the list methods. In JavaScript, you only need to know how to write a small
program with const, if, functions, and template literals, how to work with strings using
.slice(), .at(), and .indexOf(), and how to join an array’s items into a string with
.join().
A current version of Node.js 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 a summary below it, so you can review without rewatching. A project puts the whole Monday script together, and a quiz and a summary close the course.
Next up: Building the Rota as an Array, where you write the rota as a JavaScript array and read its first person, its last person, and its length.