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#81

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
danipoma merged 52 commits intojavascript-tutorial:masterfromotmon76:1.2.15
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
52 commits
Select commitHold shift + click to select a range
60715e9
1.2.15
otmon76Apr 18, 2022
4efc42b
Update solution.md
otmon76Jun 27, 2022
c38fee4
Update article.md
otmon76Jun 27, 2022
ea843c2
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
37926e7
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
c088893
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
25633ea
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
deec629
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
e83cba3
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
2d86dc3
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
a7cf5df
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
96e0a34
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
6284a04
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
6c25b52
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
9dbcf54
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
0dd5146
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
7e4f888
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
52ed0ba
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
7c46b14
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
9f9e845
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
819ddbb
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
0995d74
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
0527b60
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
99f8794
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
a1313db
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
405a4b7
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
9e5a4ea
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
8999849
Update 1-js/02-first-steps/15-function-basics/2-rewrite-function-ques…
otmon76Jul 13, 2022
f918572
Update 1-js/02-first-steps/15-function-basics/3-min/task.md
otmon76Jul 13, 2022
223451a
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
9581c5a
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
e433ba2
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
491729c
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
007d3c4
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
3e2d6ce
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
4f2806c
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
9287618
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
393a83f
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
8d1af04
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
7dfa61f
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
b37f9d3
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
655e1fd
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
34f7134
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
4e26f73
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
e2cd6ba
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
4f9e628
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
818abcf
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
493f8ed
Update 1-js/02-first-steps/15-function-basics/article.md
otmon76Jul 13, 2022
fc3cfbe
Update 1-js/02-first-steps/15-function-basics/1-if-else-required/task.md
otmon76Jul 13, 2022
a040390
Update 1-js/02-first-steps/15-function-basics/1-if-else-required/solu…
otmon76Jul 13, 2022
a47afda
Update 1-js/02-first-steps/15-function-basics/2-rewrite-function-ques…
otmon76Jul 13, 2022
f89a3fc
Merge branch 'master' into 1.2.15
danipomaJul 13, 2022
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,3 +1,3 @@
No difference!
Žádný rozdíl v nich není.

In both cases,`return confirm('Did parents allow you?')` executes exactly when the`if`condition is falsy.
V obou případech se příkaz`return confirm('Dovolili ti to rodiče?');` spustí právě tehdy, když podmínka za`if`není splněna.
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,37 +2,37 @@ importance: 4

---

#Is "else" required?
#Je nutné „else“?

The following function returns`true` if the parameter `age` is greater than `18`.
Následující funkce vrátí`true`, jestliže parametr `věk` je větší než `18`.

Otherwise it asks for a confirmation and returns its result:
Jinak se zeptá na povolení a vrátí výsledek dotazu:

```js
functioncheckAge(age) {
if (age > 18) {
functionověřVěk(věk) {
if (věk > 18) {
return true;
*!*
} else {
// ...
return confirm('Did parents allow you?');
return confirm('Dovolili ti to rodiče?');
}
*/!*
}
```

Will the function work differently if`else` is removed?
Bude tato funkce fungovat jinak, bude-li odstraněno`else`?

```js
functioncheckAge(age) {
if (age > 18) {
functionověřVěk(věk) {
if (věk > 18) {
return true;
}
*!*
// ...
return confirm('Did parents allow you?');
return confirm('Dovolili ti to rodiče?');
*/!*
}
```

Is there any difference in the behavior of these two variants?
Je nějaký rozdíl mezi chováním těchto dvou variant?
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
Using a question mark operator `'?'`:
Pomocí operátoru otazníku `'?'`:

```js
functioncheckAge(age) {
return (age > 18) ? true : confirm('Did parents allow you?');
functionověřVěk(věk) {
return (věk > 18) ? true : confirm('Dovolili ti to rodiče?');
}
```

Using OR `||` (the shortest variant):
Pomocí OR `||` (kratší varianta):

```js
functioncheckAge(age) {
return (age > 18) || confirm('Did parents allow you?');
functionověřVěk(věk) {
return (věk > 18) || confirm('Dovolili ti to rodiče?');
}
```

Note that the parentheses around `age > 18`are not required here. They exist for better readability.
Závorky okolo `věk > 18`zde nejsou nutné. Slouží jen k lepší čitelnosti.
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,25 +2,26 @@ importance: 4

---

#Rewrite the function using '?' or '||'
#Přepište funkci pomocí „?“ nebo „||“

The following function returns `true` if the parameter `age` is greater than `18`.
Následující funkce vrátí `true`, jestliže parametr `věk` je větší než `18`.

Jinak se zeptá na povolení a vrátí výsledek dotazu:

Otherwise it asks for a confirmation and returns its result.

```js
functioncheckAge(age) {
if (age > 18) {
functionověřVěk(věk) {
if (věk > 18) {
return true;
} else {
return confirm('Did parents allow you?');
return confirm('Dovolili ti to rodiče?');
}
}
```

Rewrite it, to perform the same, but without`if`, in a single line.
Přepište ji, aby dělala totéž, ale bez použití`if` a na jediný řádek.

Make two variants of `checkAge`:
Vytvořte dvě varianty `ověřVěk`:

1.Using a question mark operator `?`
2.Using OR `||`
1.Pomocí operátoru otazníku `?`
2.Pomocí OR `||`
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`:
Řešení pomocí `if`:

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

A solution with a question mark operator `'?'`:
Řešení pomocí operátoru otazníku `'?'`:

```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.V případě rovnosti`a == b`nezáleží na tom, kterou proměnnou funkce vrátí.
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)
#Funkce min(a, b)

Write a function`min(a,b)` which returns the least of two numbers`a`and `b`.
Napište funkci`min(a,b)`, která vrátí menší ze dvou čísel`a`a `b`.

For instance:
Příklady použítí:

```js
min(2, 5) == 2
Expand Down
12 changes: 6 additions & 6 deletions1-js/02-first-steps/15-function-basics/4-pow/solution.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@

```js run demo
functionpow(x, n) {
letresult = x;
functionmocnina(x, n) {
letvýsledek = x;

for (let i = 1; i < n; i++) {
result *= x;
výsledek *= x;
}

returnresult;
returnvýsledek;
}

let x = prompt("x?", '');
let n = prompt("n?", '');

if (n < 1) {
alert(`Power${n} is not supported, use a positive integer`);
alert(`${n}-tá mocnina není podporována, zadejte kladné celé číslo`);
} else {
alert(pow(x, n) );
alert(mocnina(x, n) );
}
```
14 changes: 7 additions & 7 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)
#Funkce mocnina(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.
Napište funkci `mocnina(x,n)`, která vrátí `x`umocněné na `n`-tou. Nebo, jinak řečeno, vynásobí `x`sebou samým `n`-krát a vrátí výsledek.

```js
pow(3, 2) = 3 * 3 = 9
pow(3, 3) = 3 * 3 * 3 = 27
pow(1, 100) = 1 * 1 * ...* 1 = 1
mocnina(3, 2) = 3 * 3 = 9
mocnina(3, 3) = 3 * 3 * 3 = 27
mocnina(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)`.
Vytvořte webovou stránku, která se zeptá na`x`a `n` a pak zobrazí výsledek `mocnina(x,n)`.

[demo]

P.S.In this task the function should support only natural values of`n`:integers up from `1`.
P.S.V této úloze by funkce měla podporovat jen přirozené hodnoty`n`:celá čísla větší nebo rovna `1`.
Loading

[8]ページ先頭

©2009-2025 Movatter.jp