bhylu.com

Advertisements

JS Style Guide

A style guide makes code easier for another person to read. Use consistent names, indentation, and brace placement.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

function remainingPlaces(capacity, booked) {
  return capacity - booked;
}
console.log(remainingPlaces(12, 5));

What happens

The descriptive names explain the calculation before it runs.