Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Functions (tasks, solutions)#144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tarasyyyk merged 40 commits intomasterfromfunction-basics
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
40 commits
Select commitHold shift + click to select a range
2657e40
Functions (#127)
hypeofpipeJul 13, 2021
70d7220
Translate 'Parameters'
tarasyyykJul 13, 2021
b5037dc
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykJul 21, 2021
c3baaa4
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykJul 21, 2021
d6836ea
Translate 'default values'
tarasyyykAug 2, 2021
09129f1
Merge branch 'function-basics' of github.com:javascript-tutorial/uk.j…
tarasyyykAug 2, 2021
4a323cb
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 4, 2021
c81076a
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 4, 2021
3b15e47
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 4, 2021
b3ee6b3
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 4, 2021
90a0055
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 4, 2021
2f752e7
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 4, 2021
75bdab2
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 4, 2021
2927bdf
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 4, 2021
a9c06b2
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 4, 2021
8fa0670
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 4, 2021
998c089
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 4, 2021
c81cd91
Merge branch 'master' into function-basics
tarasyyykAug 4, 2021
c9a4759
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 4, 2021
551e343
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 4, 2021
d13a0a5
Translate 'Alternative default parameters'
tarasyyykAug 4, 2021
63a71ac
Fix lines
tarasyyykAug 4, 2021
69b1d4e
Translate 'Returning value'
tarasyyykAug 8, 2021
5e69205
Translate 'Naming a function'
tarasyyykAug 10, 2021
a92a590
Translate 'Functions == Comments'
tarasyyykAug 11, 2021
bbef865
Translate 'Summary'
tarasyyykAug 12, 2021
49c7498
Translate tasks
tarasyyykAug 12, 2021
35a7e7b
Small correction
tarasyyykAug 12, 2021
d8b912e
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 12, 2021
c04547d
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 12, 2021
c593e1c
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 12, 2021
d7782b5
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 12, 2021
94edb76
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 12, 2021
e07b2db
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 12, 2021
da2c2b9
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 12, 2021
fade570
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 12, 2021
061af87
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 12, 2021
8c7507d
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 12, 2021
24f31a2
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 12, 2021
f866d6a
Update 1-js/02-first-steps/15-function-basics/article.md
tarasyyykAug 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
No difference.
Обидва варіанти працюють однаково, різниці немає.
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,11 @@ importance: 4

---

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

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

Otherwise it asks for a confirmation and returns its result:
Інакше вона запитує підтвердження через `confirm` і повертає його результат:

```js
function checkAge(age) {
Expand All@@ -15,13 +15,13 @@ function checkAge(age) {
*!*
} else {
// ...
return confirm('Did parents allow you?');
return confirm('Батьки дозволили?');
}
*/!*
}
```

Will the function work differently if`else` is removed?
Чи буде функція працювати по-іншому, якщо забрати`else`?

```js
function checkAge(age) {
Expand All@@ -30,9 +30,9 @@ function checkAge(age) {
}
*!*
// ...
return confirm('Did parents allow you?');
return confirm('Батьки дозволили?');
*/!*
}
```

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

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

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

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

Note that the parentheses around`age > 18`are not required here. They exist for better readability.
Зверніть увагу, що круглі дужки навколо`age > 18`не обов’язкові. Вони тут для кращої читабельності коду.
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,25 +2,25 @@ importance: 4

---

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

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

Otherwise it asks for a confirmation and returns its result.
Інакше вона запитує підтвердження через `confirm` і повертає його результат:

```js
function checkAge(age) {
if (age > 18) {
return true;
} else {
return confirm('Did parents allow you?');
return confirm('Батьки дозволили?');
}
}
```

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

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

1.Using a question mark operator `?`
2.Using OR `||`
1.Використовуючи оператор `?`
2.Використовуючи оператор АБО `||`
6 changes: 3 additions & 3 deletions1-js/02-first-steps/15-function-basics/3-min/solution.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
A solution using `if`:
Використовуючи `if`:

```js
function min(a, b) {
Expand All@@ -10,12 +10,12 @@ function min(a, b) {
}
```

A solution with a question mark operator `'?'`:
Використовуючи оператор `'?'`:

```js
function min(a, b) {
return a < b ? a : b;
}
```

P.S.In the case of an equality`a == b`it does not matter what to return.
P.S.У випадку рівності чисел`a == b`немає значення, що повертати.
6 changes: 3 additions & 3 deletions1-js/02-first-steps/15-function-basics/3-min/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,11 @@ importance: 1

---

#Function min(a, b)
#Функція min(a, b)

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

For instance:
Наприклад:

```js
min(2, 5) == 2
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@ let x = prompt("x?", '');
let n = prompt("n?", '');

if (n < 1) {
alert(`Power ${n}is not supported, use a positive integer`);
alert(`Степінь ${n}не підтримується, використовуйте натуральне число`);
} else {
alert( pow(x, n) );
}
Expand Down
8 changes: 4 additions & 4 deletions1-js/02-first-steps/15-function-basics/4-pow/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,18 +2,18 @@ importance: 4

---

#Function pow(x,n)
#Функція pow(x,n)

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

```js
pow(3, 2) = 3 * 3 = 9
pow(3, 3) = 3 * 3 * 3 = 27
pow(1, 100) = 1 * 1 * ...* 1 = 1
```

Create a web-page that prompts for`x`and `n`,and then shows the result of`pow(x,n)`.
Створіть сторінку, яка запитує`x`та `n`,а потім показує результат`pow(x,n)`.

[demo]

P.S.In this task the function should support only natural values of`n`: integers up from `1`.
P.S.В цій задачі функція повинна підтримувати лише натуральні значення`n`, тобто цілі числа, починаючи з `1`.
Loading

[8]ページ先頭

©2009-2025 Movatter.jp