Skip to content

Commit 4cad987

Browse files
authored
Merge pull request #85 from dyrpit/14-function-basics
Functions
2 parents b6bd0c5 + 551d348 commit 4cad987

File tree

9 files changed

+193
-193
lines changed

9 files changed

+193
-193
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
No difference.
1+
Nie ma żadnej różnicy.

1-js/02-first-steps/14-function-basics/1-if-else-required/task.md

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

33
---
44

5-
# Is "else" required?
5+
# Czy "else" jest wymagane?
66

7-
The following function returns `true` if the parameter `age` is greater than `18`.
7+
Następująca funkcja zwraca `true` jeżeli parametr `age` jest większy niż `18`.
88

9-
Otherwise it asks for a confirmation and returns its result:
9+
W przeciwnym razie prosi o potwierdzenie i zwraca wynik:
1010

1111
```js
1212
function checkAge(age) {
@@ -15,13 +15,13 @@ function checkAge(age) {
1515
*!*
1616
} else {
1717
// ...
18-
return confirm('Did parents allow you?');
18+
return confirm('Czy rodzice ci pozwolili?');
1919
}
2020
*/!*
2121
}
2222
```
2323

24-
Will the function work differently if `else` is removed?
24+
Czy funkcja będzie działać inaczej jeżeli `else` zostanie usunięte?
2525

2626
```js
2727
function checkAge(age) {
@@ -30,9 +30,9 @@ function checkAge(age) {
3030
}
3131
*!*
3232
// ...
33-
return confirm('Did parents allow you?');
33+
return confirm('Czy rodzice ci pozwolili?');
3434
*/!*
3535
}
3636
```
3737

38-
Is there any difference in the behavior of these two variants?
38+
Czy jest jakakolwiek różnica w zachowaniu tych dwóch wariantów?
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
Using a question mark operator `'?'`:
1+
Przy użyciu operatora warunkowego `'?'`:
22

33
```js
44
function checkAge(age) {
5-
return (age > 18) ? true : confirm('Did parents allow you?');
5+
return (age > 18) ? true : confirm('Czy rodzice ci pozwolili?');
66
}
77
```
88

9-
Using OR `||` (the shortest variant):
9+
Używając logicznego OR `||` (krótszy wariant):
1010

1111
```js
1212
function checkAge(age) {
13-
return (age > 18) || confirm('Did parents allow you?');
13+
return (age > 18) || confirm('Czy rodzice ci pozwolili?');
1414
}
1515
```
1616

17-
Note that the parentheses around `age > 18` are not required here. They exist for better readabilty.
17+
Zwróć uwagę że nawiasy wokół `age > 18` nie są tutaj wymagane. Są tutaj dla lepszej czytelności.

1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/task.md

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

33
---
44

5-
# Rewrite the function using '?' or '||'
5+
# Przepisz funkcję używając '?' lub '||'
66

7-
The following function returns `true` if the parameter `age` is greater than `18`.
7+
Następująca funkcja zwraca `true` jeżeli parametr `age` jest większy niż `18`.
88

9-
Otherwise it asks for a confirmation and returns its result.
9+
W przeciwnym razie prosi o potwierdzenie i zwraca wynik.
1010

1111
```js
1212
function checkAge(age) {
1313
if (age > 18) {
1414
return true;
1515
} else {
16-
return confirm('Did parents allow you?');
16+
return confirm('Czy rodzice ci pozwolili?');
1717
}
1818
}
1919
```
2020

21-
Rewrite it, to perform the same, but without `if`, in a single line.
21+
Przepisz ją, aby zachowywała się tak samo, ale bez `if`, w żadnej z lini.
2222

23-
Make two variants of `checkAge`:
23+
Stwórz dwa warianty `checkAge`:
2424

25-
1. Using a question mark operator `?`
26-
2. Using OR `||`
25+
1. Przy użyciu operatora warunkowego `?`
26+
2. Używając logicznego OR `||`

1-js/02-first-steps/14-function-basics/3-min/solution.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
A solution using `if`:
1+
Rozwiązanie z wykorzystaniem `if`:
22

33
```js
44
function min(a, b) {
@@ -10,12 +10,12 @@ function min(a, b) {
1010
}
1111
```
1212

13-
A solution with a question mark operator `'?'`:
13+
Rozwiązanie z wykorzystaniem operatora warunkowego `'?'`:
1414

1515
```js
1616
function min(a, b) {
1717
return a < b ? a : b;
1818
}
1919
```
2020

21-
P.S. In the case of an equality `a == b` it does not matter what to return.
21+
P.S. W przypadku równości `a == b` nie ma znaczenia co zostanie zwrócone.

1-js/02-first-steps/14-function-basics/3-min/task.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 1
22

33
---
44

5-
# Function min(a, b)
5+
# Funkcja min(a, b)
66

7-
Write a function `min(a,b)` which returns the least of two numbers `a` and `b`.
7+
Napisz funkcję `min(a,b)` która zwraca najmniejszą z dwóch liczb `a` i `b`.
88

9-
For instance:
9+
Na przykład:
1010

1111
```js
1212
min(2, 5) == 2

1-js/02-first-steps/14-function-basics/4-pow/solution.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let x = prompt("x?", '');
1414
let n = prompt("n?", '');
1515

1616
if (n < 1) {
17-
alert(`Power ${n} is not supported, use a positive integer`);
17+
alert(`Potęga z ${n} nie jest wspierana, użyj dodatniej liczby całkowitej`);
1818
} else {
1919
alert( pow(x, n) );
2020
}

1-js/02-first-steps/14-function-basics/4-pow/task.md

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

33
---
44

5-
# Function pow(x,n)
5+
# Funkcja pow(x,n)
66

7-
Write a function `pow(x,n)` that returns `x` in power `n`. Or, in other words, multiplies `x` by itself `n` times and returns the result.
7+
Napisz funkcję `pow(x,n)` która zwraca `x` podniesione do potęgi `n`. Lub, innymi słowy, mnoży `x` przez samą siebie `n` razy i zwraca rezultat.
88

99
```js
1010
pow(3, 2) = 3 * 3 = 9
1111
pow(3, 3) = 3 * 3 * 3 = 27
1212
pow(1, 100) = 1 * 1 * ...* 1 = 1
1313
```
1414

15-
Create a web-page that prompts for `x` and `n`, and then shows the result of `pow(x,n)`.
15+
Stwórz stronę internetową która wyświetla okno dialogowe i prosi od podanie `x` oraz `n`, a następnie pokazuje rezultat `pow(x,n)`.
1616

1717
[demo]
1818

19-
P.S. In this task the function should support only natural values of `n`: integers up from `1`.
19+
P.S. W tym zadaniu funkcja powinna wspierać jedynie naturalne wartości `n`: liczby całkowite od `1` wzwyż.

0 commit comments

Comments
 (0)