Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Porting the Release Note

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 capital True: JavaScript writes true and false in lowercase.
  • Rename open_bugs to openBugs. Set let statusLine with braced if/else: JavaScript’s if is a statement, so it can’t supply an assignment’s value. A shorter expression form comes later.
  • print() calls and f-strings become console.log() calls and template literals.
  • Brace even a one-line body. The empty else needs no pass; keep its TODO comment. JavaScript would resolve pass as a name if the branch ran.
  • The mutable deployers use let and 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:

Language: JavaScript
/**
 * 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);

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

00:00 In this project, you’ll port the release note script to JavaScript, check it, and run it. The Python script has six settings, a status line, a bug check, and a deployer swap.

00:14 The code freeze warning and closing message are left for the exercise; the warning reads the code freeze setting.

00:22 JavaScript has no docstrings: this one becomes a JSDoc block comment, opening with an extra star. The hash comment turns into two slashes.

00:34 The six settings get const declarations and keep their capitals; const prevents reassignment. Watch out for Python’s capital True: JavaScript writes true and false in lowercase.

00:48 open_bugs becomes camel case, and stays a const, since nothing reassigns it. A let and braced if…else set the status line: JavaScript’s if is a statement, so it can’t be an assignment’s value.

01:03 You’ll meet a shorter expression form later. The two prints turn into console.log() calls, each f-string a template literal.

01:14 The JavaScript bug check keeps braces even around one line, so a later addition stays inside. Empty braces need no pass: drop it and keep the TODO comment; JavaScript would resolve pass as a name if that branch ran.

01:32 At the end comes the handover. Both deployers are lets, because the swap reassigns them. The swap becomes destructuring, with square brackets on both sides.

01:44 Keep the semicolon after Theo: without it, the leading bracket would join the preceding declaration.

01:53 In the release-note folder, package.json sets "type" to "module", so release-note.js is an ECMAScript module in strict mode.

02:02 Both commands run from this folder. First, check the file with node --check, which parses it and runs nothing. It prints nothing at all, so the syntax is valid.

02:16 Now run it, and the note comes out in four lines. Each one matches its line in Python’s note, needs attention included.

02:26 Keep the logic, change the syntax, then check and run. Next up is the exercise Finish the Release Note: add the code freeze warning and closing message, and compare the output with Python’s.

Become a Member to join the conversation.