You made it. Dev’s digest now runs in JavaScript. node digest.js logs/week-44.log 75 prints the same report as digest.py and adds the week to season.txt.
In this course, you learned how to:
- Export what other files need and import it by its relative path,
./and.jsincluded - Tell a default import from a named one in braces, and import built-ins from
node:names - Run the program at the entry file’s top level, with
if (import.meta.main)for a self-check - Take the arguments from
process.argv.slice(2)and convert the limit withNumber() - Report a usage error with
console.error()andprocess.exitCode = 1 - Read with
await readFile(path, "utf8"), split withtext.trim().split("\n"), and append to a path built fromimport.meta.dirname
Drop the Habits That Misfire
As in Python, modules have their own scope and load once, arguments are strings, usage errors go to standard error, and relative readFile() paths start from the folder you run node in. Wrong output often comes from NaN, a promise, or an argument that’s one position off. These habits misfire: