Skip to content

Commit 5b16f00

Browse files
committed
2 parents 899e3e1 + 43c1978 commit 5b16f00

File tree

13 files changed

+33
-32
lines changed

13 files changed

+33
-32
lines changed

1-js/02-first-steps/06-type-conversions/1-primitive-conversions-questions/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ undefined + 1 = NaN // (4)
1717
```
1818

1919
1. The addition with a string `"" + 1` converts `1` to a string: `"" + 1 = "1"`, and then we have `"1" + 0`, the same rule is applied.
20-
2. The substruction `"-"` (like most math operations) only works with numbers, it converts an empty string `""` to `0`.
20+
2. The subtraction `"-"` (like most math operations) only works with numbers, it converts an empty string `""` to `0`.
2121
3. `null` becomes `0` after the numeric conversion.
2222
4. `undefined` becomes `NaN` after the numeric conversion.

1-js/02-first-steps/07-operators/article.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ alert( b ); // 4
173173
alert( c ); // 4
174174
```
175175
176-
Chained assignments evaluate from right to left. First the rightmost expression `2+2` is evaluated then assigned to the variables on the left: `c`, `b` and `a`. At the end, all variables share a single value.
176+
Chained assignments evaluate from right to left. First the rightmost expression `2 + 2` is evaluated then assigned to the variables on the left: `c`, `b` and `a`. At the end, all variables share a single value.
177177
178178
````smart header="The assignment operator `\"=\"` returns a value"
179179
An operator always returns a value. That's obvious for most of them like an addition `+` or a multiplication `*`. But the assignment operator follows that rule too.
@@ -381,8 +381,8 @@ This notation can be shortened using operators `+=` and `*=`:
381381
382382
```js run
383383
let n = 2;
384-
n += 5; // now n=7 (same as n = n + 5)
385-
n *= 2; // now n=14 (same as n = n * 2)
384+
n += 5; // now n = 7 (same as n = n + 5)
385+
n *= 2; // now n = 14 (same as n = n * 2)
386386
387387
alert( n ); // 14
388388
```
@@ -409,18 +409,18 @@ For example:
409409
410410
```js run
411411
*!*
412-
let a = (1+2, 3+4);
412+
let a = (1 + 2, 3 + 4);
413413
*/!*
414414
415-
alert( a ); // 7 (the result of 3+4)
415+
alert( a ); // 7 (the result of 3 + 4)
416416
```
417417
418-
Here, the first expression `1+2` is evaluated, and its result is thrown away, then `3+4` is evaluated and returned as the result.
418+
Here, the first expression `1 + 2` is evaluated, and its result is thrown away, then `3 + 4` is evaluated and returned as the result.
419419
420420
```smart header="Comma has a very low precedence"
421421
Please note that the comma operator has very low precedence, lower than `=`, so parentheses are important in the example above.
422422
423-
Without them: `a=1+2,3+4` evaluates `+` first, summing the numbers into `a=3,7`, then the assignment operator `=` assigns `a=3`, and then the number after the comma `7` is not processed anyhow, so it's ignored.
423+
Without them: `a = 1 + 2, 3 + 4` evaluates `+` first, summing the numbers into `a = 3, 7`, then the assignment operator `=` assigns `a = 3`, and then the number after the comma `7` is not processed anyhow, so it's ignored.
424424
```
425425
426426
Why do we need such an operator which throws away everything except the last part?

1-js/02-first-steps/12-while-for/3-which-value-for/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ for (let i = 0; i < 5; i++) alert( i );
88

99
That can be easily deducted from the algorithm of `for`:
1010

11-
1. Execute once `i=0` before everything (begin).
12-
2. Check the condition `i<5`
11+
1. Execute once `i = 0` before everything (begin).
12+
2. Check the condition `i < 5`
1313
3. If `true` -- execute the loop body `alert(i)`, and then `i++`
1414

1515
The increment `i++` is separated from the condition check (2). That's just another statement.

1-js/02-first-steps/12-while-for/7-list-primes/task.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ importance: 3
66

77
An integer number greater than `1` is called a [prime](https://en.wikipedia.org/wiki/Prime_number) if it cannot be divided without a remainder by anything except `1` and itself.
88

9-
In other words, `n>1` is a prime if it can't be evenly divided by anything except `1` and `n`.
9+
In other words, `n > 1` is a prime if it can't be evenly divided by anything except `1` and `n`.
1010

1111
For example, `5` is a prime, because it cannot be divided without a remainder by `2`, `3` and `4`.
1212

1313
**Write the code which outputs prime numbers in the interval from `2` to `n`.**
1414

15-
For `n=10` the result will be `2,3,5,7`.
15+
For `n = 10` the result will be `2,3,5,7`.
1616

1717
P.S. The code should work for any `n`, not be hard-tuned for any fixed value.

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ while (condition) {
2121

2222
While the `condition` is `true`, the `code` from the loop body is executed.
2323

24-
For instance, the loop below outputs `i` while `i<3`:
24+
For instance, the loop below outputs `i` while `i < 3`:
2525

2626
```js run
2727
let i = 0;
@@ -37,7 +37,7 @@ If there were no `i++` in the example above, the loop would repeat (in theory) f
3737

3838
Any expression or a variable can be a loop condition, not just a comparison. They are evaluated and converted to boolean by `while`.
3939

40-
For instance, the shorter way to write `while (i!=0)` could be `while (i)`:
40+
For instance, the shorter way to write `while (i != 0)` could be `while (i)`:
4141

4242
```js run
4343
let i = 3;
@@ -108,8 +108,8 @@ Let's examine the `for` statement part by part:
108108

109109
| part | | |
110110
|-------|----------|----------------------------------------------------------------------------|
111-
| begin | `i=0` | Executes once upon entering the loop. |
112-
| condition | `i<3`| Checked before every loop iteration, if fails the loop stops. |
111+
| begin | `i = 0` | Executes once upon entering the loop. |
112+
| condition | `i < 3`| Checked before every loop iteration, if fails the loop stops. |
113113
| step| `i++` | Executes after the body on each iteration, but before the condition check. |
114114
| body | `alert(i)`| Runs again and again while the condition is truthy |
115115

@@ -188,11 +188,11 @@ We can also remove the `step` part:
188188
let i = 0;
189189

190190
for (; i < 3;) {
191-
alert( i );
191+
alert( i++ );
192192
}
193193
```
194194

195-
The loop became identical to `while (i<3)`.
195+
The loop became identical to `while (i < 3)`.
196196

197197
We can actually remove everything, thus creating an infinite loop:
198198

@@ -324,7 +324,7 @@ The ordinary `break` after `input` would only break the inner loop. That's not s
324324

325325
A *label* is an identifier with a colon before a loop:
326326
```js
327-
labelName: for(...) {
327+
labelName: for (...) {
328328
...
329329
}
330330
```
@@ -369,7 +369,7 @@ For example, it is impossible to do this:
369369
```js
370370
break label; // jumps to label? No.
371371
372-
label: for(...)
372+
label: for (...)
373373
```
374374
375375
The call to a `break/continue` is only possible from inside the loop, and the label must be somewhere upwards from the directive.
@@ -381,7 +381,7 @@ We covered 3 types of loops:
381381

382382
- `while` -- The condition is checked before each iteration.
383383
- `do..while` -- The condition is checked after each iteration.
384-
- `for(;;)` -- The condition is checked before each iteration, additional settings available.
384+
- `for (;;)` -- The condition is checked before each iteration, additional settings available.
385385

386386
To make an "infinite" loop, usually the `while(true)` construct is used. Such a loop, just like any other, can be stopped with the `break` directive.
387387

1-js/02-first-steps/15-function-expressions-arrows/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,9 @@ If we have only one argument, then parentheses can be omitted, making that even
403403

404404
```js run
405405
// same as
406-
// let double = function(n) { return n*2 }
406+
// let double = function(n) { return n * 2 }
407407
*!*
408-
let double = n => n*2;
408+
let double = n => n * 2;
409409
*/!*
410410

411411
alert( double(3) ); // 6

1-js/02-first-steps/16-javascript-specials/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ switch (age) {
216216
alert("Won't work"); // the result of prompt is a string, not a number
217217
218218
case "18":
219-
alert("This works!"");
219+
alert("This works!");
220220
break;
221221
222222
default:
@@ -273,7 +273,7 @@ We covered three ways to create a function in JavaScript:
273273
274274
275275
- Functions may have local variables: those declared inside its body. Such variables are only visible inside the function.
276-
- Parameters can have default values: `function sum(a=1, b=2) {...}`.
276+
- Parameters can have default values: `function sum(a = 1, b = 2) {...}`.
277277
- Functions always return something. If there's no `return` statement, then the result is `undefined`.
278278
279279

1-js/03-code-quality/03-comments/article.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ function showPrimes(n) {
5858

5959
function isPrime(n) {
6060
for (let i = 2; i < n; i++) {
61-
if ( n % i == 0) return false;
61+
if (n % i == 0) return false;
6262
}
63+
6364
return true;
6465
}
6566
```

1-js/04-object-basics/03-symbol/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Till now we've only seen strings. Now let's see the advantages that symbols can
99

1010
## Symbols
1111

12-
"Symbol" value represents an unique identifier.
12+
"Symbol" value represents a unique identifier.
1313

1414
A value of this type can be created using `Symbol()`:
1515

@@ -141,7 +141,7 @@ let user = {
141141
};
142142

143143
*!*
144-
for(let key in user) alert(key); // name, age (no symbols)
144+
for (let key in user) alert(key); // name, age (no symbols)
145145
*/!*
146146

147147
// the direct access by the symbol works

2-ui/1-document/03-dom-navigation/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ The first thing is nice. The second is tolerable, because we can use `Array.from
157157
```warn header="DOM collections are read-only"
158158
DOM collections, and even more -- *all* navigation properties listed in this chapter are read-only.
159159
160-
We can't replace an child by something else assigning `childNodes[i] = ...`.
160+
We can't replace a child by something else assigning `childNodes[i] = ...`.
161161
162162
Changing DOM needs other methods, we'll see them in the next chapter.
163163
```

0 commit comments

Comments
 (0)