Porting the Release Note
You ported the settings, status line, bug check, and deployer swap without changing the logic. The code-freeze warning and closing message remain for the exercise.
- JavaScript has no docstrings: the opening text becomes a JSDoc block comment, beginning
/**. Change#comments to//. - The six editable top-level settings keep UPPER_SNAKE_CASE and use
const, which prevents reassignment. Watch out for Python’s capitalTrue: JavaScript writestrueandfalsein lowercase. - Rename
open_bugstoopenBugs. Setlet statusLinewith bracedif/else: JavaScript’sifis a statement, so it can’t supply an assignment’s value. A shorter expression form comes later. print()calls and f-strings becomeconsole.log()calls and template literals.- Brace even a one-line body. The empty
elseneeds nopass; keep its TODO comment. JavaScript would resolvepassas a name if the branch ran. - The mutable deployers use
letand swap with brackets on both sides. Keep the semicolon after"Theo": otherwise the leading bracket would continue the preceding declaration.
Here’s release-note.js, in release-note/, whose package.json contains { "type": "module" }. That makes this an ECMAScript module, which runs in strict mode. The two exercise parts are still to come:
/**
* Print the end-of-day release note.
*/
// Edit these settings before each run.
const CLIENT = "Fernleaf Bakery";
const VERSION = "2.4.1";
const DEPLOYED_BY = "Maya";
const BUGS_OPENED = 9;
const BUGS_CLOSED = 7;
const CODE_FREEZE = true;
const openBugs = BUGS_OPENED - BUGS_CLOSED;
let statusLine;
if (openBugs === 0) {
statusLine = "all clear";
} else {
statusLine = "needs attention";
}
console.log(`Release ${VERSION} for ${CLIENT}`);
console.log(`Status: ${statusLine}`);
if (openBugs > 0) {
console.log("Open bugs:", openBugs);
} else {
// TODO: link the bug tracker
}
let deployer = DEPLOYED_BY;
let nextDeployer = "Theo";
[deployer, nextDeployer] = [nextDeployer, deployer];
console.log("Next:", deployer, "then", nextDeployer);