Skip to content

Commit 9e08a7e

Browse files
committed
Fix several mistakes in Chapter 9
1 parent cb1e99a commit 9e08a7e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

09_regexp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ console.log(getDate("30-1-2003"));
448448
{{index destructuring, "underscore character"}}
449449

450450
The `_` (underscore) binding is ignored, and only used to "skip" the
451-
full match element in the array returned by `match`.
451+
full match element in the array returned by `exec`.
452452

453453
## Word and string boundaries
454454

@@ -1112,7 +1112,7 @@ the match to a binding and immediately use that assignment as the test
11121112
in the `if` statement.
11131113

11141114
If a line is not a section header or a property, the function checks
1115-
whether it is a comment or an emty line using the expression
1115+
whether it is a comment or an empty line using the expression
11161116
`/^\s*(;.*)?$/`. Do you see how it works? The part between the
11171117
((parentheses)) will match comments, and the `?` makes sure it also
11181118
matches lines containing only whitespace. When a line doesn't match

code/solutions/09_3_numbers_again.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ let number = /^(\+|-|)(\d+(\.\d*)?|\.\d+)([eE](\+|-|)\d+)?$/;
44
// Tests:
55
for (let str of ["1", "-1", "+15", "1.55", ".5", "5.",
66
"1.3e2", "1E-4", "1e+12"]) {
7-
if (!number.test(s)) {
8-
console.log("Failed to match '" + s + "'");
7+
if (!number.test(str)) {
8+
console.log(`Failed to match '${str}'`);
99
}
1010
}
1111
for (let str of ["1a", "+-1", "1.2.3", "1+1", "1e4.5",
1212
".5.", "1f5", "."]) {
13-
if (number.test(s)) {
14-
console.log("Incorrectly accepted '" + s + "'");
13+
if (number.test(str)) {
14+
console.log(`Incorrectly accepted '${str}'`);
1515
}
1616
}
1717

0 commit comments

Comments
 (0)