Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f21f302

Browse files
tarasyyykhypeofpipeUkrainianCitizendolgachio
authoredAug 12, 2021
Functions (#144)
* Functions (#127) * First part of article.md * Translate 'Alternative default parameters' * Fix lines * Translate 'Returning value' * Translate 'Naming a function' * Translate 'Functions == Comments' * Translate 'Summary' * Translate tasks * Small correction Co-authored-by: Volodymyr V <14982064+hypeofpipe@users.noreply.github.com> Co-authored-by: UkrainianCitizen <31314423+UkrainianCitizen@users.noreply.github.com> Co-authored-by: Stanislav <s.dolgachov@gmail.com>
1 parent e435dc9 commit f21f302

File tree

9 files changed

+207
-207
lines changed

9 files changed

+207
-207
lines changed
 
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
No difference.
1+
Обидва варіанти працюють однаково, різниці немає.

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 4
22

33
---
44

5-
# Is "else" required?
5+
# Чи потрібен "else"?
66

7-
The following function returns `true` if the parameter `age` is greater than `18`.
7+
Наступна функція повертає `true`, якщо параметр `age` більший за `18`.
88

9-
Otherwise it asks for a confirmation and returns its result:
9+
Інакше вона запитує підтвердження через `confirm` і повертає його результат:
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('Батьки дозволили?');
1919
}
2020
*/!*
2121
}
2222
```
2323

24-
Will the function work differently if `else` is removed?
24+
Чи буде функція працювати по-іншому, якщо забрати `else`?
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('Батьки дозволили?');
3434
*/!*
3535
}
3636
```
3737

38-
Is there any difference in the behavior of these two variants?
38+
Чи є різниця в поведінці цих двох варіантів?
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
Using a question mark operator `'?'`:
1+
Використовуючи оператор `'?'`:
22

33
```js
44
function checkAge(age) {
5-
return (age > 18) ? true : confirm('Did parents allow you?');
5+
return (age > 18) ? true : confirm('Батьки дозволили?');
66
}
77
```
88

9-
Using OR `||` (the shortest variant):
9+
Використовуючи оператор АБО `||` (найкоротший варіант):
1010

1111
```js
1212
function checkAge(age) {
13-
return (age > 18) || confirm('Did parents allow you?');
13+
return (age > 18) || confirm('Батьки дозволили?');
1414
}
1515
```
1616

17-
Note that the parentheses around `age > 18` are not required here. They exist for better readability.
17+
Зверніть увагу, що круглі дужки навколо `age > 18` не обов’язкові. Вони тут для кращої читабельності коду.

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ importance: 4
22

33
---
44

5-
# Rewrite the function using '?' or '||'
5+
# Перепишіть функцію, використовуючи '?' або '||'
66

7-
The following function returns `true` if the parameter `age` is greater than `18`.
7+
Наступна функція повертає `true`, якщо параметр `age` більший за `18`.
88

9-
Otherwise it asks for a confirmation and returns its result.
9+
Інакше вона запитує підтвердження через `confirm` і повертає його результат:
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('Батьки дозволили?');
1717
}
1818
}
1919
```
2020

21-
Rewrite it, to perform the same, but without `if`, in a single line.
21+
Перепишіть функцію, щоб вона робила теж саме, але без `if` і в один рядок.
2222

23-
Make two variants of `checkAge`:
23+
Зробіть два варіанти функції `checkAge`:
2424

25-
1. Using a question mark operator `?`
26-
2. Using OR `||`
25+
1. Використовуючи оператор `?`
26+
2. Використовуючи оператор АБО `||`

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
A solution using `if`:
1+
Використовуючи `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+
Використовуючи оператор `'?'`:
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. У випадку рівності чисел `a == b` немає значення, що повертати.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 1
22

33
---
44

5-
# Function min(a, b)
5+
# Функція min(a, b)
66

7-
Write a function `min(a,b)` which returns the least of two numbers `a` and `b`.
7+
Напишіть функцію `min(a, b)`, яка повертає менше з двох чисел `a` та `b`.
88

9-
For instance:
9+
Наприклад:
1010

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

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

Lines changed: 1 addition & 1 deletion
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(`Степінь ${n} не підтримується, використовуйте натуральне число`);
1818
} else {
1919
alert( pow(x, n) );
2020
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ importance: 4
22

33
---
44

5-
# Function pow(x,n)
5+
# Функція 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+
Напишіть функцію `pow(x, n)`, яка повертає число `x`, піднесене до степеня `n`. Інакше кажучи, множить число `x` саме на себе `n` разів і повертає результат.
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+
Створіть сторінку, яка запитує `x` та `n`, а потім показує результат `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. В цій задачі функція повинна підтримувати лише натуральні значення `n`, тобто цілі числа, починаючи з `1`.

‎1-js/02-first-steps/15-function-basics/article.md

Lines changed: 175 additions & 175 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.