Skip to content

Commit 8991d30

Browse files
authored
Merge pull request #2675 from johan456789/patch-1
Rewrite sentences to make it clearer
2 parents 30db2f6 + 2b7aa48 commit 8991d30

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/content/1/en/part1d.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ The solution does not quite work:
288288

289289
![browser showing 2 left|right 1, RLL total 2](../../images/1/33.png)
290290

291-
For some reason the total of button presses is all the time one behind the actual amount of presses.
291+
The total number of button presses is consistently one less than the actual amount of presses, for some reason.
292292

293293
Let us add couple of console.log statements to the event handler:
294294

@@ -311,7 +311,7 @@ The console reveals the problem
311311

312312
![devtools console showing left before 4 and left after 4](../../images/1/32.png)
313313

314-
Even though a new value was set to _left_ by calling _setLeft(left + 1)_, the old value is still there despite the update! Because of this, the following attempt to count button presses produces a too small result:
314+
Even though a new value was set for _left_ by calling _setLeft(left + 1)_, the old value persists despite the update. As a result, the attempt to count button presses produces a result that is too small:
315315

316316
```js
317317
setTotal(left + right)
@@ -478,7 +478,7 @@ If and when your code fails to compile and your browser lights up like a Christm
478478
![screenshot of code](../../images/1/6x.png)
479479

480480
don't write more code but rather find and fix the problem **immediately**. There has yet to be a moment in the history of coding where code that fails to compile would miraculously start working after writing large amounts of additional code. I highly doubt that such an event will transpire during this course either.
481-
481+
482482
Old-school, print-based debugging is always a good idea. If the component
483483

484484
```js
@@ -505,25 +505,25 @@ const Button = (props) => {
505505

506506
This will immediately reveal if, for instance, one of the attributes has been misspelled when using the component.
507507

508-
**NB** When you use _console.log_ for debugging, don't combine _objects_ in a Java-like fashion by using the plus operator. Instead of writing:
508+
**NB** When you use _console.log_ for debugging, don't combine _objects_ in a Java-like fashion by using the plus operator:
509509

510510
```js
511511
console.log('props value is ' + props)
512512
```
513-
514-
Separate the things you want to log to the console with a comma:
513+
514+
If you do that, you will end up with a rather uninformative log message:
515515

516516
```js
517-
console.log('props value is', props)
517+
props value is [object Object]
518518
```
519519

520-
If you use the Java-like way of concatenating a string with an object, you will end up with a rather uninformative log message:
520+
Instead, separate the things you want to log to the console with a comma:
521521

522522
```js
523-
props value is [object Object]
523+
console.log('props value is', props)
524524
```
525525

526-
Whereas the items separated by a comma will all be available in the browser console for further inspection.
526+
In this way, the separated items will all be available in the browser console for further inspection.
527527

528528
Logging output to the console is by no means the only way of debugging our applications. You can pause the execution of your application code in the Chrome developer console's <i>debugger</i>, by writing the command [debugger](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger) anywhere in your code.
529529

0 commit comments

Comments
 (0)