Skip to content

Commit b538c0b

Browse files
committed
2 parents ca7a248 + 0b207b5 commit b538c0b

File tree

293 files changed

+2461
-26921
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

293 files changed

+2461
-26921
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* text=auto eol=lf
2+
*.svg binary
2.08 KB
Loading
Loading

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

Lines changed: 0 additions & 24 deletions
This file was deleted.

1-js/02-first-steps/07-type-conversions/1-primitive-conversions-questions/task.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

1-js/02-first-steps/10-ifelse/2-check-standard/task.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ If the visitor enters "ECMAScript", then output "Right!", otherwise -- output: "
1111
![](ifelse_task2.svg)
1212

1313
[demo src="ifelse_task2"]
14-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The answer: `null`, because it's the first falsy value from the list.
22

33
```js run
4-
alert( 1 && null && 2 );
4+
alert(1 && null && 2);
55
```
66

1-js/02-first-steps/11-logical-operators/9-check-login/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ if (userName === 'Admin') {
99

1010
if (pass === 'TheMaster') {
1111
alert( 'Welcome!' );
12-
} else if (pass == '' || pass == null) {
13-
alert( 'Canceled.' );
12+
} else if (pass === '' || pass === null) {
13+
alert( 'Canceled' );
1414
} else {
1515
alert( 'Wrong password' );
1616
}

1-js/02-first-steps/11-logical-operators/9-check-login/task.md

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

77
Write the code which asks for a login with `prompt`.
88

9-
If the visitor enters `"Admin"`, then `prompt` for a password, if the input is an empty line or `key:Esc` -- show "Canceled.", if it's another string -- then show "I don't know you".
9+
If the visitor enters `"Admin"`, then `prompt` for a password, if the input is an empty line or `key:Esc` -- show "Canceled", if it's another string -- then show "I don't know you".
1010

1111
The password is checked as follows:
1212

1313
- If it equals "TheMaster", then show "Welcome!",
1414
- Another string -- show "Wrong password",
15-
- For an empty string or cancelled input, show "Canceled."
15+
- For an empty string or cancelled input, show "Canceled"
1616

1717
The schema:
1818

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ For example, outputting goods from a list one after another or just running the
66

77
*Loops* are a way to repeat the same code multiple times.
88

9+
```smart header="The for..of and for..in loops"
10+
A small announcement for advanced readers.
11+
12+
This article covers only basic loops: `while`, `do..while` and `for(..;..;..)`.
13+
14+
If you came to this article searching for other types of loops, here are the pointers:
15+
16+
- See [for..in](info:object#forin) to loop over object properties.
17+
- See [for..of](info:array#loops) and [iterables](info:iterable) for looping over arrays and iterable objects.
18+
19+
Otherwise, please read on.
20+
```
21+
922
## The "while" loop
1023

1124
The `while` loop has the following syntax:
@@ -162,10 +175,8 @@ for (i = 0; i < 3; i++) { // use an existing variable
162175
163176
alert(i); // 3, visible, because declared outside of the loop
164177
```
165-
166178
````
167179

168-
169180
### Skipping parts
170181

171182
Any part of `for` can be skipped.
@@ -268,7 +279,7 @@ for (let i = 0; i < 10; i++) {
268279

269280
From a technical point of view, this is identical to the example above. Surely, we can just wrap the code in an `if` block instead of using `continue`.
270281

271-
But as a side-effect, this created one more level of nesting (the `alert` call inside the curly braces). If the code inside of `if` is longer than a few lines, that may decrease the overall readability.
282+
But as a side effect, this created one more level of nesting (the `alert` call inside the curly braces). If the code inside of `if` is longer than a few lines, that may decrease the overall readability.
272283
````
273284
274285
````warn header="No `break/continue` to the right side of '?'"
@@ -286,7 +297,6 @@ if (i > 5) {
286297
287298
...and rewrite it using a question mark:
288299
289-
290300
```js no-beautify
291301
(i > 5) ? alert(i) : *!*continue*/!*; // continue isn't allowed here
292302
```
@@ -321,6 +331,7 @@ We need a way to stop the process if the user cancels the input.
321331
The ordinary `break` after `input` would only break the inner loop. That's not sufficient -- labels, come to the rescue!
322332

323333
A *label* is an identifier with a colon before a loop:
334+
324335
```js
325336
labelName: for (...) {
326337
...
@@ -342,6 +353,7 @@ The `break <labelName>` statement in the loop below breaks out to the label:
342353
// do something with the value...
343354
}
344355
}
356+
345357
alert('Done!');
346358
```
347359

@@ -362,13 +374,15 @@ The `continue` directive can also be used with a label. In this case, code execu
362374
Labels do not allow us to jump into an arbitrary place in the code.
363375
364376
For example, it is impossible to do this:
377+
365378
```js
366379
break label; // jump to the label below (doesn't work)
367380
368381
label: for (...)
369382
```
370383
371384
A `break` directive must be inside a code block. Technically, any labelled code block will do, e.g.:
385+
372386
```js
373387
label: {
374388
// ...

0 commit comments

Comments
 (0)