Loading video player…

Welcome to the Weather Station Check

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:

Language: Python
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:

Language: Program Output
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:

Language: JavaScript
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:

Language: Program Output
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.

Download

Sample Code (.zip)

8.6 KB
Download

Course Slides (.pdf)

716.9 KB

00:00 Welcome to JavaScript Equality and Type Checks for Pythonistas! It’s 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.

00:17 You’ll port a weather co-op’s Python script that checks each hour’s readings from its four stations, ridge, mill, orchard and school, and skips any reading a station sends twice.

00:28 Here’s a first taste. In Python, the check skips the second ridge reading and counts three readings checked. In the port, the skip line asks seen.includes(reading) instead.

00:43 JavaScript prints the ridge line twice, and the count says four readings checked. There’s no error. That’s the kind of difference this course is about.

00:55 The Millbrook Valley Weather Co-op’s volunteers run four home weather stations. Their script checks each hour’s readings before they go on the website: it skips resent readings, rejects bad fields, and describes the rest.

01:09 The website runs on JavaScript, so the check is moving there too.

01:15 You’ll compare records and values, check types and classes, and read the rules behind each equality check. And at the end, you’ll port the whole check.

01:27 You need to know how Python’s ==, is and isinstance() work, and how to write small JavaScript programs. Any current Node is fine.

01:39 Videos mix with text lessons and exercises, and every video has a summary below it. A quiz and a summary close the course.

01:48 Next, in Comparing Records by Identity, you’ll start porting the check with its skip line.

Become a Member to join the conversation.