You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/07-operators/article.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -173,7 +173,7 @@ alert( b ); // 4
173
173
alert( c ); // 4
174
174
```
175
175
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.
177
177
178
178
````smart header="The assignment operator `\"=\"` returns a value"
179
179
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 `*=`:
381
381
382
382
```js run
383
383
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)
386
386
387
387
alert( n ); // 14
388
388
```
@@ -409,18 +409,18 @@ For example:
409
409
410
410
```js run
411
411
*!*
412
-
let a = (1+2, 3+4);
412
+
let a = (1 + 2, 3 + 4);
413
413
*/!*
414
414
415
-
alert( a ); // 7 (the result of 3+4)
415
+
alert( a ); // 7 (the result of 3 + 4)
416
416
```
417
417
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.
419
419
420
420
```smart header="Comma has a very low precedence"
421
421
Please note that the comma operator has very low precedence, lower than `=`, so parentheses are important in the example above.
422
422
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.
424
424
```
425
425
426
426
Why do we need such an operator which throws away everything except the last part?
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/12-while-for/7-list-primes/task.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,12 @@ importance: 3
6
6
7
7
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.
8
8
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`.
10
10
11
11
For example, `5` is a prime, because it cannot be divided without a remainder by `2`, `3` and `4`.
12
12
13
13
**Write the code which outputs prime numbers in the interval from `2` to `n`.**
14
14
15
-
For `n=10` the result will be `2,3,5,7`.
15
+
For `n = 10` the result will be `2,3,5,7`.
16
16
17
17
P.S. The code should work for any `n`, not be hard-tuned for any fixed value.
0 commit comments