marijnh / Eloquent-JavaScript

The sources for the Eloquent JavaScript book
https://eloquentjavascript.net
3.03k stars 799 forks source link

Misplaced semicolons #274

Closed clmay closed 6 years ago

clmay commented 6 years ago

Hey Marijn,

Founds some semicolons lurking in places I did not expect to find them. Some are legal but unnecessary and possible style violations, depending which guide you prefer.

Here:

const square = function(x) {
  return x * x;
}; // <---

And also here:

const makeNoise = function() {
  console.log("Pling!");
}; // <---

const power = function(base, exponent) {
  let result = 1;
  for (let count = 0; count < exponent; count++) {
    result *= base;
  }
  return result;
}; // <---

In fact, there are several more throughout Chapter 3; guessing they're just leftovers from sketching out the examples that were not removed yet.

marijnh commented 6 years ago

These are all required by the grammar if you ignore automatic semicolon insertion, and my policy in the book is to include every semicolon.