Your port’s statements now end where you mean them to. The next line in release_note.py to port is the status line, the two words Fernleaf Bakery’s team reads first: “all clear” when no bugs are open, “needs attention” otherwise. With 9 bugs opened and 7 closed today, the note should say “needs attention”.
In Python, that’s a one-liner. In JavaScript, the same one-liner won’t even start, and the reason is a question worth asking of every line you port: does this produce a value? In this lesson, you’ll learn where JavaScript draws that line and how to port the status line around it.
Ask Whether a Line Produces a Value
You already know this split from Python. An expression is code that produces a value: BUGS_OPENED - BUGS_CLOSED gives 2, and open_bugs == 0 gives False. A statement is a step the program takes, such as an if, a for loop, or an import. You can put an expression anywhere Python expects a value, inside print() or an f-string’s braces. You can’t put a statement there.
JavaScript makes the same split, and the value slots are the ones you’d guess: the parentheses of console.log() and the ${} slots of a template literal. Here’s the top of the port, with three expressions dropped into templates:
const BUGS_OPENED = 9;
const BUGS_CLOSED = 7;
const openBugs = BUGS_OPENED - BUGS_CLOSED;
console.log(`Bugs: ${BUGS_OPENED} opened, ${BUGS_CLOSED} closed`);
console.log(`Still open: ${openBugs}`);
console.log(`All closed: ${openBugs === 0}`);