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

+1
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

-24
This file was deleted.

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

-26
This file was deleted.

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

-1
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-
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

+2-2
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

+2-2
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

+18-4
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
// ...
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
To precisely match the functionality of `switch`, the `if` must use a strict comparison `'==='`.
1+
Para precisamente se equiparar à funcionalidade do `switch`, o `if` deve utilizar uma comparação exata `'==='`.
22

3-
For given strings though, a simple `'=='` works too.
3+
Contudo, para certas *strings*, um simples `'=='` também funciona.
44

55
```js no-beautify
66
if(browser == 'Edge') {
7-
alert("You've got the Edge!");
7+
alert("Você usa o Edge!");
88
} else if (browser == 'Chrome'
99
|| browser == 'Firefox'
1010
|| browser == 'Safari'
1111
|| browser == 'Opera') {
12-
alert( 'Okay we support these browsers too' );
12+
alert( 'Okay, também suportamos esse navegador.' );
1313
} else {
14-
alert( 'We hope that this page looks ok!' );
14+
alert( 'Esperamos que esta página tenha uma boa apresentação!' );
1515
}
1616
```
1717

18-
Please note: the construct `browser == 'Chrome' || browser == 'Firefox' …` is split into multiple lines for better readability.
18+
Por favor, note: a construção `browser == 'Chrome' || browser == 'Firefox' …` está repartida por múltiplas linhas para melhor leitura.
1919

20-
But the `switch` construct is still cleaner and more descriptive.
20+
Mas a construção `switch` ainda é mais clara e descritiva.

1-js/02-first-steps/14-switch/1-rewrite-switch-if-else/task.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ importance: 5
22

33
---
44

5-
# Rewrite the "switch" into an "if"
5+
# Transforme o "switch" num "if"
66

7-
Write the code using `if..else` which would correspond to the following `switch`:
7+
Escreva o código empregando `if..else` que corresponda ao seguinte `switch`:
88

99
```js
1010
switch (browser) {
1111
case 'Edge':
12-
alert( "You've got the Edge!" );
12+
alert( "Você usa o Edge!" );
1313
break;
1414

1515
case 'Chrome':
1616
case 'Firefox':
1717
case 'Safari':
1818
case 'Opera':
19-
alert( 'Okay we support these browsers too' );
19+
alert( 'Okay, também suportamos esse navegador' );
2020
break;
2121

2222
default:
23-
alert( 'We hope that this page looks ok!' );
23+
alert( 'Esperamos que esta página tenha uma boa apresentação!' );
2424
}
2525
```
2626

1-js/02-first-steps/14-switch/2-rewrite-if-switch/solution.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The first two checks turn into two `case`. The third check is split into two cases:
1+
As duas primeiras comparações transformam-se em dois `case`. A terceira comparação está divida em dois casos:
22

33
```js run
44
let a = +prompt('a?', '');
@@ -21,6 +21,6 @@ switch (a) {
2121
}
2222
```
2323

24-
Please note: the `break` at the bottom is not required. But we put it to make the code future-proof.
24+
Por favor, note: o `break` no final não é necessário. Mas o colocamos como segurança no código.
2525

26-
In the future, there is a chance that we'd want to add one more `case`, for example `case 4`. And if we forget to add a break before it, at the end of `case 3`, there will be an error. So that's a kind of self-insurance.
26+
No futuro, poderemos querer colocar mais um `case`, por exemplo `case 4`. E se nos esquecermos de adicionar um break antes dele, no final de `case 3`, ocorrerá um erro. Assim, é uma espécie de prevenção.

1-js/02-first-steps/14-switch/2-rewrite-if-switch/task.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 4
22

33
---
44

5-
# Rewrite "if" into "switch"
5+
# Transforme o "if" num "switch"
66

7-
Rewrite the code below using a single `switch` statement:
7+
Reescreva o código abaixo empregando uma única instrução `switch`:
88

99
```js run
1010
let a = +prompt('a?', '');

0 commit comments

Comments
 (0)