This course is about JavaScript’s comparisons and type checks: Python’s == and is operators,
isinstance() and math.isnan() each have a counterpart that answers a slightly different question. Along the way, you’ll port a weather co-op’s Python script that checks each hour’s
readings.
Here’s a first taste. The script’s main loop skips any reading a station sent twice. Here it is in Python, with the field checks folded into one line:
seen = []
checked = 0
for reading in batch:
name = f"{reading['station']} #{reading['seq']}"
if reading in seen:
print(f"Skipped resent {name}")
else:
seen.append(reading)
# ... reject bad fields, or print the line and count it
print(f"{checked} readings checked")
For the 09:00 batch, where the ridge station sent the same reading twice, Python skips the copy and counts three readings:
ridge #1412: 6.5°C, 0.2 mm rain, at 54.61, -3.05
mill #877: 7.4°C (unchanged), dry, at 54.58, -3.11
Skipped resent ridge #1412
orchard #2290: no temperature (unchanged), no rain data, no GPS
Rejected school #96: bad fields
3 readings checked
Here’s the loop ported line by line, where the skip line asks seen.includes(reading) instead:
const seen = [];
let checked = 0;
for (const reading of batch) {
const name = `${reading.station} #${reading.seq}`;
if (seen.includes(reading)) {
console.log(`Skipped resent ${name}`);
} else {
seen.push(reading);
// ... reject bad fields, or print the line and count it
}
}
console.log(`${checked} readings checked`);
JavaScript prints the ridge line twice, and the count says four readings checked:
ridge #1412: 6.5°C, 0.2 mm rain, at 54.61, -3.05
mill #877: 7.4°C (unchanged), dry, at 54.58, -3.11
ridge #1412: 6.5°C, 0.2 mm rain, at 54.61, -3.05
orchard #2290: no temperature (unchanged), no rain data, no GPS
Rejected school #96: bad fields
4 readings checked
There’s no error. That’s the kind of difference this course is about.
The Millbrook Valley Weather Co-op’s volunteers run four home weather stations: ridge, mill, orchard and school. Their Python script checks each hour’s readings before they go on the website: it skips resent readings, rejects readings with bad fields, and describes the rest. The website runs on JavaScript, so the check is moving there too.
By the end of this course, you’ll be able to:
- Compare records and values, and see what happens when you try to change a string
- Check a value’s type, and an object’s class
- Read the rules
==follows, and compare temperatures, failed readings included - Port the whole readings check to JavaScript
You need to know how Python’s ==, is and isinstance() work, and what mutability means. In
JavaScript, you need to know how to write small programs with const and let, ===, typeof,
functions, arrays and objects, and know null from undefined. Any current version of Node.js is
fine: 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.
Next, in the video Comparing Records by Identity, you’ll start porting the check with its skip line.