Splitting Long Lines

The end-of-day release note needs a code freeze warning and a closing message. Both stretch across several source lines. You already end JavaScript statements with semicolons. Now you’ll choose breaks that keep each statement together, without carrying Python’s continuation syntax into the port.

Split the Warning

Python’s parenthesized condition lets you put CODE_FREEZE and and open_bugs > 0 on separate lines. JavaScript’s if already requires parentheses around its condition, so break inside them:

Language: JavaScript
const CODE_FREEZE = true;
const openBugs = 2;

if (
  CODE_FREEZE &&
  openBugs > 0
) {
  console.log(
    "Hold tomorrow's deploy until the open bugs are closed."
  );
}

Run the port to print today’s warning:

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.