Skip to content

Commit 7df7e50

Browse files
committed
Integrate editing for Chapter 4
1 parent f247543 commit 7df7e50

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

04_data.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ named "x", `value[x]` tries to evaluate the expression `x` and uses
164164
the result as the property name.
165165

166166
So if you know that the property you are interested in is called
167-
"name", you say `value.name`. If you want to extract the property
167+
_name_, you say `value.name`. If you want to extract the property
168168
named by the value held in the binding `i`, you say `value[i]`.
169169
Property names can be any string, but the dot notation only works with
170170
names that look like valid binding names. So if you want to access a
171-
property named "2" or "John Doe", you must use square brackets:
171+
property named _2_ or _John Doe_, you must use square brackets:
172172
`value[2]` or `value["John Doe"]`.
173173

174174
The elements in an ((array)) are stored as the array's properties, using
@@ -243,7 +243,7 @@ and returning it.
243243
These somewhat silly names are the traditional terms for operations on
244244
a _((stack))_. A stack, in programming, is a ((data structure)) that
245245
allows you to push values into it and pop them out again in the
246-
opposite order, so the thing that was added last is removed first.
246+
opposite order, so that the thing that was added last is removed first.
247247
These are common in programming—you might remember the function ((call
248248
stack)) from [the previous chapter](functions#stack), which is an
249249
instance of the same idea.
@@ -284,7 +284,7 @@ console.log(day1.wolf);
284284
Inside the braces, there is a list of properties separated by commas.
285285
Each property has a name followed by a colon and a value. When an
286286
object is written over multiple lines, indenting it like in the
287-
example helps with readability. Properties whose names are not valid
287+
example helps with readability. Properties whose names aren't valid
288288
binding names or valid numbers have to be quoted.
289289

290290
```
@@ -457,12 +457,12 @@ the same object, the _contents_ of that object might change.
457457

458458
{{index "== operator", [comparison, "of objects"], "deep comparison"}}
459459

460-
When you compare objects with JavaScript's `==` operator it will
460+
When you compare objects with JavaScript's `==` operator, it will
461461
produce `true` only if both objects are precisely the same value.
462462
Comparing different objects will return `false`, even if they have
463463
identical properties. There is no "deep" comparison operation built
464464
into JavaScript, which compares objects by contents, but it is
465-
possible to write it yourself (which will be one of the
465+
possible to write it yourself (which is one of the
466466
[exercises](data#exercise_deep_compare) at the end of this chapter).
467467

468468
## The lycanthrope's log
@@ -559,7 +559,7 @@ if}}
559559
(If at this point you're putting the book down to focus on a terrible
560560
flashback to 10th grade math class—hold on! I do not intend to torture
561561
you with endless pages of cryptic notation—just this one formula for
562-
now. And even with that one, all we do is turn it into JavaScript.)
562+
now. And even with this one, all we do is turn it into JavaScript.)
563563

564564
The notation [_n_~01~]{if html}[[$n_{01}$]{latex}]{if tex} indicates
565565
the number of measurements where the first variable (squirrelness) is
@@ -783,7 +783,7 @@ for (let event of journalEvents(JOURNAL)) {
783783
// → peanuts: 0.5902679812
784784
```
785785

786-
A-ha! There are two factors whose ((correlation)) is clearly stronger
786+
A-ha! There are two factors with a ((correlation)) that's clearly stronger
787787
than the others. Eating ((peanuts)) has a strong positive effect on
788788
the chance of turning into a squirrel, whereas brushing his teeth has
789789
a significant negative effect.
@@ -826,7 +826,7 @@ vanishes into the forest. He is never seen again.
826826
{{index [array, methods], method}}
827827

828828
Before finishing the chapter, I want to introduce you to a few more
829-
object-related concepts. We'll start by introducing some generally
829+
object-related concepts. I'll start by introducing some generally
830830
useful array methods.
831831

832832
{{index "push method", "pop method", "shift method", "unshift method"}}
@@ -860,7 +860,7 @@ adds it to the front instead of the back of the queue.
860860
{{index [array, searching], "indexOf method", "lastIndexOf method"}}
861861

862862
To search for a specific value, arrays provide an `indexOf` method. It
863-
goes through the array from the start to the end, and returns the
863+
goes through the array from the start to the end and returns the
864864
index at which the requested value was found—or -1 if it wasn't found.
865865
To search from the end instead of the start, there's a similar method
866866
called `lastIndexOf`.
@@ -900,7 +900,7 @@ The `concat` method can be used to glue arrays together to create a
900900
new array, similar to what the `+` operator does for strings. The
901901
following example shows both `concat` and `slice` in action. It takes
902902
an array and an index, and it returns a new array that is a copy of
903-
the original array with the element at the given index removed.
903+
the original array with the element at the given index removed:
904904

905905
```
906906
function remove(array, index) {
@@ -912,7 +912,7 @@ console.log(remove(["a", "b", "c", "d", "e"], 2));
912912
```
913913

914914
If you pass `concat` an argument that is not an array, that value will
915-
be added to the new array as if it was a one-element array.
915+
be added to the new array as if it were a one-element array.
916916

917917
## Strings and their properties
918918

@@ -1147,8 +1147,8 @@ console.log(Math.random());
11471147

11481148
Though computers are deterministic machines—they always react the same
11491149
way if given the same input—it is possible to have them produce
1150-
numbers that appear random. To do this, the machine keeps some hidden
1151-
value, and whenever you ask for a new random number, it'll perform
1150+
numbers that appear random. To do that, the machine keeps some hidden
1151+
value, and whenever you ask for a new random number, it performs
11521152
complicated computations on this hidden value to create a new value.
11531153
It stores a new value and returns some number derived from it. That
11541154
way, it can produce ever new, hard-to-predict numbers in a way that
@@ -1197,7 +1197,7 @@ function phi(table) {
11971197

11981198
One of the reasons this function is awkward to read is that we have a
11991199
binding pointing at our array, but we'd much prefer to have bindings
1200-
for the _elements_ of the array. I.e. `let n00 = table[0]`, and so on.
1200+
for the _elements_ of the array, that is, `let n00 = table[0]` and so on.
12011201
Fortunately, there is a succinct way to do this in JavaScript.
12021202

12031203
```
@@ -1229,14 +1229,14 @@ console.log(name);
12291229
{{index null, undefined}}
12301230

12311231
Note that if you try to destructure `null` or `undefined`, you get an
1232-
error, much like you would if you'd directly try to access a property
1232+
error, much as you would if you directly try to access a property
12331233
of those values.
12341234

12351235
## JSON
12361236

12371237
{{index [array, representation], [object, representation], "data format"}}
12381238

1239-
Because properties only grasp their value, rather than containing it,
1239+
Because properties only grasp their value, rather than contain it,
12401240
objects and arrays are stored in the computer's ((memory)) as
12411241
sequences of bits holding the _((address))es_—the place in memory—of
12421242
their contents. So an array with another array inside of it consists
@@ -1389,7 +1389,7 @@ by writing two separate loops—one for counting up and one for counting
13891389
down—because the comparison that checks whether the loop is finished
13901390
needs to be `>=` rather than `<=` when counting downward.
13911391

1392-
It might also be worthwhile to use a different default step, namely,
1392+
It might also be worthwhile to use a different default step, namely
13931393
-1, when the end of the range is smaller than the start. That way,
13941394
`range(5, 2)` returns something meaningful, rather than getting stuck
13951395
in an ((infinite loop)). It is possible to refer to previous
@@ -1437,9 +1437,9 @@ if}}
14371437
There are two obvious ways to implement `reverseArray`. The first is
14381438
to simply go over the input array from front to back and use the
14391439
`unshift` method on the new array to insert each element at its start.
1440-
The second is to loop over the input array backward and use the `push`
1441-
method. Iterating over an array backward requires a (somewhat awkward)
1442-
`for` specification like `(let i = array.length - 1; i >= 0; i--)`.
1440+
The second is to loop over the input array backwards and use the `push`
1441+
method. Iterating over an array backwards requires a (somewhat awkward)
1442+
`for` specification, like `(let i = array.length - 1; i >= 0; i--)`.
14431443

14441444
{{index "slice method"}}
14451445

@@ -1500,7 +1500,7 @@ original list is also still a valid three-element list.
15001500

15011501
Write a function `arrayToList` that builds up a list structure like
15021502
the one shown when given `[1, 2, 3]` as argument. Also write a
1503-
`listToArray` function that produces an array from a list. Then, add a
1503+
`listToArray` function that produces an array from a list. Then add a
15041504
helper function `prepend`, which takes an element and a list and
15051505
creates a new list that adds the element to the front of the input
15061506
list, and `nth`, which takes a list and a number and returns the
@@ -1532,7 +1532,7 @@ if}}
15321532
{{index "list (exercise)", "linked list"}}
15331533

15341534
Building up a list is easier when done back to front. So `arrayToList`
1535-
could iterate over the array backward (see previous exercise) and, for
1535+
could iterate over the array backwards (see previous exercise) and, for
15361536
each element, add an object to the list. You can use a local binding
15371537
to hold the part of the list that was built so far and use an
15381538
assignment like `list = {value: X, rest: list}` to add an element.
@@ -1570,10 +1570,10 @@ hint}}
15701570

15711571
{{index "deep comparison (exercise)", comparison, "deep comparison", "== operator"}}
15721572

1573-
The `==` operator compares objects by identity. But sometimes, you
1574-
would prefer to compare the values of their actual properties.
1573+
The `==` operator compares objects by identity. But sometimes you'd
1574+
prefer to compare the values of their actual properties.
15751575

1576-
Write a function, `deepEqual`, that takes two values and returns true
1576+
Write a function `deepEqual` that takes two values and returns true
15771577
only if they are the same value or are objects with the same
15781578
properties, where the values of the properties are equal when compared
15791579
with a recursive call to `deepEqual`.

0 commit comments

Comments
 (0)