Skip to content

Commit f137e50

Browse files
committed
Update 1-02 after pr-178 (11,13)
1 parent 9661942 commit f137e50

File tree

3 files changed

+12
-115
lines changed

3 files changed

+12
-115
lines changed
Lines changed: 0 additions & 104 deletions
Loading

1-js/02-first-steps/11-logical-operators/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ This leads to some interesting usage compared to a "pure, classical, boolean-onl
101101

102102
1. **Getting the first truthy value from a list of variables or expressions.**
103103

104-
For instance, we have `firstName`, `lastName` and `nickName` variables, all optional (i.e. can be undefined or have falsy values).
104+
For instance, we have `firstName`, `lastName` and `nickName` variables, all optional (i.e. can be undefined or have falsy values).
105105

106106
Let's use OR `||` to choose the one that has the data and show it (or `"Anonymous"` if nothing set):
107107

@@ -173,7 +173,7 @@ if (1 && 0) { // evaluated as true && false
173173
```
174174

175175

176-
## AND finds the first falsy value
176+
## AND "&&" finds the first falsy value
177177

178178
Given multiple AND'ed values:
179179

1-js/02-first-steps/13-while-for/article.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ while (condition) {
1717
}
1818
```
1919

20-
While the `condition` is `true`, the `code` from the loop body is executed.
20+
While the `condition` is truthy, the `code` from the loop body is executed.
2121

2222
For instance, the loop below outputs `i` while `i < 3`:
2323

@@ -47,8 +47,8 @@ while (i) { // when i becomes 0, the condition becomes falsy, and the loop stops
4747
}
4848
```
4949

50-
````smart header="Brackets are not required for a single-line body"
51-
If the loop body has a single statement, we can omit the brackets `{…}`:
50+
````smart header="Curly braces are not required for a single-line body"
51+
If the loop body has a single statement, we can omit the curly braces `{…}`:
5252
5353
```js run
5454
let i = 3;
@@ -84,7 +84,7 @@ This form of syntax should only be used when you want the body of the loop to ex
8484

8585
## The "for" loop
8686

87-
The `for` loop is the most commonly used loop.
87+
The `for` loop is more complex, but it's also the most commonly used loop.
8888

8989
It looks like this:
9090

@@ -111,8 +111,8 @@ Let's examine the `for` statement part-by-part:
111111
| body | `alert(i)`| Runs again and again while the condition is truthy. |
112112
| step| `i++` | Executes after the body on each iteration. |
113113

114-
115114
The general loop algorithm works like this:
115+
116116
```
117117
Run begin
118118
→ (if condition → run body and run step)
@@ -121,6 +121,8 @@ Run begin
121121
→ ...
122122
```
123123

124+
That is, `begin` executes once, and then it iterates: after each `condition` test, `body` and `step` are executed.
125+
124126
If you are new to loops, it could help to go back to the example and reproduce how it runs step-by-step on a piece of paper.
125127

126128
Here's exactly what happens in our case:
@@ -289,8 +291,7 @@ if (i > 5) {
289291
(i > 5) ? alert(i) : *!*continue*/!*; // continue isn't allowed here
290292
```
291293
292-
...it stops working. Code like this will give a syntax error:
293-
294+
...it stops working: there's a syntax error.
294295
295296
This is just another reason not to use the question mark operator `?` instead of `if`.
296297
````
@@ -357,12 +358,12 @@ for (let i = 0; i < 3; i++) { ... }
357358

358359
The `continue` directive can also be used with a label. In this case, code execution jumps to the next iteration of the labeled loop.
359360

360-
````warn header="Labels are not a \"goto\""
361+
````warn header="Labels do not allow to \"jump\" anywhere"
361362
Labels do not allow us to jump into an arbitrary place in the code.
362363
363364
For example, it is impossible to do this:
364365
```js
365-
break label; // jumps to label? No.
366+
break label; // doesn't jumps to the label below
366367
367368
label: for (...)
368369
```

0 commit comments

Comments
 (0)