Skip to content

Commit e69ace1

Browse files
committed
Pass over chapter 3
Update scoping explanation for block scope, introduce arrow functions, lots of small tweaks.
1 parent 44a8045 commit e69ace1

7 files changed

Lines changed: 524 additions & 548 deletions

File tree

01_values.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ The next basic data type is the _((string))_. Strings are used to
238238
represent text. They are written by enclosing their content in quotes.
239239

240240
```
241-
"Down on the sea"
242-
'Lie on the ocean'
243-
`Float on the ocean`
241+
`Down on the sea`
242+
"Lie on the ocean"
243+
'Float on the ocean'
244244
```
245245

246246
You can use single quotes, double quotes, or backticks to mark

02_program_structure.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ a certain condition holds. For example, in the previous example
391391
program, we might want to show the square of the input only if the
392392
input is actually a number.
393393

394-
```
394+
```{test: wrap}
395395
let theNumber = Number(prompt("Pick a number"));
396396
if (!isNaN(theNumber)) {
397397
console.log("Your number is the square root of " +
@@ -422,7 +422,7 @@ is represented by the second arrow in the diagram. The `else` keyword
422422
can be used, together with `if`, to create two separate, alternative
423423
execution paths.
424424

425-
```
425+
```{test: wrap}
426426
let theNumber = Number(prompt("Pick a number"));
427427
if (!isNaN(theNumber)) {
428428
console.log("Your number is the square root of " +
@@ -654,7 +654,7 @@ cases, this is shorter and clearer than a `while` construct.
654654

655655
This is the code that computes 2^10^, using `for` instead of `while`:
656656

657-
```
657+
```{test: wrap}
658658
let result = 1;
659659
for (let counter = 0; counter < 10; counter = counter + 1)
660660
result = result * 2;
@@ -681,9 +681,11 @@ that is both greater than or equal to 20 and divisible by 7.
681681

682682
```
683683
for (let current = 20; ; current = current + 1) {
684-
if (current % 7 == 0) break;
684+
if (current % 7 == 0) {
685+
console.log(current);
686+
break;
687+
}
685688
}
686-
console.log(current);
687689
// → 21
688690
```
689691

0 commit comments

Comments
 (0)