Skip to content

Commit 76ae6b4

Browse files
committed
Integrate tech editing for Chapter 2
1 parent 582c2e3 commit 76ae6b4

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

02_program_structure.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ console.log(mood);
136136
You should imagine bindings as tentacles, rather than boxes. They do
137137
not _contain_ values; they _grasp_ them—two bindings can refer to the
138138
same value. A program can only access the values that it still has a
139-
hold on. When you need to remember something, you grow a tentacle to
140-
hold on to it or you reattach one of your existing tentacles to it.
139+
reference to. When you need to remember something, you grow a tentacle
140+
to hold on to it or you reattach one of your existing tentacles to it.
141141

142142
Let's look at another example. To remember the number of dollars that
143143
Luigi still owes you, you create a binding. And then when he pays back
@@ -188,23 +188,22 @@ in this book because it has some confusing properties.
188188
{{index "const keyword", naming}}
189189

190190
The word `const` stands for _((constant))_. It defines a constant
191-
binding, which cannot be made to point at a new thing. This is useful
192-
for bindings that give a name to a value so that you can easily refer
193-
to them later, but which are not going to ever change.
191+
binding, which points at the same value for as long as it lives. This
192+
is useful for bindings that give a name to a value so that you can
193+
easily refer to it later.
194194

195195
## Binding names
196196

197197
{{index "underscore character", "dollar sign", [binding, naming]}}
198198

199-
Binding names can be any word that isn't reserved for some other
200-
purpose (such as `let`). Digits can be part of binding names—`catch22`
201-
is a valid name, for example—but the name must not start with a digit.
202-
A binding name may include dollar signs (`$`) or underscores (`_`), but
203-
no other punctuation or special characters.
199+
Binding names can be any word. Digits can be part of binding
200+
names—`catch22` is a valid name, for example—but the name must not
201+
start with a digit. A binding name may include dollar signs (`$`) or
202+
underscores (`_`), but no other punctuation or special characters.
204203

205204
{{index syntax, "implements (reserved word)", "interface (reserved word)", "package (reserved word)", "private (reserved word)", "protected (reserved word)", "public (reserved word)", "static (reserved word)", "void operator", "yield (reserved word)", "enum (reserved word)", "reserved word", [binding, naming]}}
206205

207-
Words with a special meaning, such as `const`, are _((keyword))s_, and
206+
Words with a special meaning, such as `let`, are _((keyword))s_, and
208207
they may not be used as binding names. There are also a number of
209208
words that are "reserved for use" in ((future)) versions of
210209
JavaScript, which also can't be used as binding names. The full list
@@ -386,7 +385,7 @@ square of the input only if the input is actually a number.
386385

387386
```{test: wrap}
388387
let theNumber = Number(prompt("Pick a number"));
389-
if (!isNaN(theNumber)) {
388+
if (!Number.isNaN(theNumber)) {
390389
console.log("Your number is the square root of " +
391390
theNumber * theNumber);
392391
}
@@ -399,10 +398,10 @@ of a Boolean expression. The deciding expression is written after the
399398
keyword, between ((parentheses)), followed by the statement to
400399
execute.
401400

402-
{{index "isNaN function"}}
401+
{{index "Number.isNaN function"}}
403402

404-
The `isNaN` function is a standard JavaScript function that returns
405-
`true` only if the argument it is given is `NaN`. The `Number`
403+
The `Number.isNaN` function is a standard JavaScript function that
404+
returns `true` only if the argument it is given is `NaN`. The `Number`
406405
function happens to return `NaN` when you give it a string that
407406
doesn't represent a valid number. Thus, the condition translates to
408407
"unless `theNumber` is not-a-number, do this".
@@ -433,7 +432,7 @@ execution paths.
433432

434433
```{test: wrap}
435434
let theNumber = Number(prompt("Pick a number"));
436-
if (!isNaN(theNumber)) {
435+
if (!Number.isNaN(theNumber)) {
437436
console.log("Your number is the square root of " +
438437
theNumber * theNumber);
439438
} else {
@@ -489,8 +488,9 @@ console.log(12);
489488

490489
That works, but the idea of writing a program is to make something
491490
_less_ work, not more. If we needed all even numbers less than 1,000,
492-
this approach would be unworkable. What we need is a way to repeat
493-
some code. This form of control flow is called a _((loop))_:
491+
this approach would be unworkable. What we need is a way to run a
492+
piece of code multiple times. This form of control flow is called a
493+
_((loop))_:
494494

495495
{{figure {url: "img/controlflow-loop.svg", alt: "Loop control flow",width: "4cm"}}}
496496

08_error.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ such values are `null`, `undefined`, or -1.
383383
```{test: no}
384384
function promptNumber(question) {
385385
let result = Number(prompt(question));
386-
if (isNaN(result)) return null;
386+
if (Number.isNaN(result)) return null;
387387
else return result;
388388
}
389389

0 commit comments

Comments
 (0)