Telling Expressions From Statements

Fernleaf Bakery’s release note needs a status: “all clear” with no open bugs, “needs attention” otherwise. Today’s nine opened and seven closed leave two. You’ll port Python’s status selection by checking which parts of JavaScript can supply a value.

Identify the Value Positions

The expression/statement split carries over from Python: an expression produces a value, while a statement directs execution. JavaScript’s console.log() prints expression values, and template literals insert them into ${} slots. Names such as openBugs, subtraction such as BUGS_OPENED - BUGS_CLOSED, and comparisons such as openBugs === 0 all fit those positions. The === comparison checks equality.

Declarations such as let statusLine; and const BUGS_OPENED = 9; can’t supply values to those positions. They introduce names. Likewise, a { at the start of a statement opens a block, grouping statements rather than supplying a value.

Choose the Status Before Printing

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

Become a Member to join the conversation.