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

Variables#71

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 19 commits intojavascript-tutorial:masterfromotmon76:1.2.4
May 1, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
19 commits
Select commitHold shift + click to select a range
252ff35
1.2.4
otmon76Apr 18, 2022
a40a638
Update 1-js/02-first-steps/04-variables/1-hello-variables/solution.md
otmon76May 1, 2022
c9559f5
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
d7ac7b7
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
3313951
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
3b60317
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
0920762
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
0366c03
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
7b74e6a
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
382245b
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
e9f6c7b
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
bbf06a0
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
6342ef5
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
32ae0eb
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
0c82c47
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
0fa31db
Update 1-js/02-first-steps/04-variables/article.md
otmon76May 1, 2022
830a94f
Update 1-js/02-first-steps/04-variables/article.md
danipomaMay 1, 2022
a95c871
Update 1-js/02-first-steps/04-variables/article.md
danipomaMay 1, 2022
f050a8c
Update 1-js/02-first-steps/04-variables/article.md
danipomaMay 1, 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,12 +1,12 @@
In the code below, each line corresponds to the item in the task list.
V níže uvedeném kódu každý řádek odpovídá jednomu bodu v zadání.

```js run
letadmin, name; //can declare two variables at once
letsprávce, jméno; //můžeme deklarovat dvě proměnné najednou

name = "John";
jméno = "Jan";

admin =name;
správce =jméno;

alert(admin ); // "John"
alert(správce ); // "Jan"
```

10 changes: 5 additions & 5 deletions1-js/02-first-steps/04-variables/1-hello-variables/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@ importance: 2

---

#Working with variables
#Práce s proměnnými

1.Declare two variables: `admin` and `name`.
2.Assign the value `"John"` to `name`.
3.Copy the value from `name` to `admin`.
4.Show the value of `admin` using `alert` (must output "John").
1.Deklarujte dvě proměnné: `správce` a `jméno`.
2.Přiřaďte do proměnné `jméno` hodnotu `"Jan"`.
3.Zkopírujte hodnotu z proměnné `jméno` do proměnné `správce`.
4.Zobrazte hodnotu proměnné `správce` pomocí `alert` (musí vypsat „Jan“).
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
##The variable for our planet
##Proměnná pro naši planetu

That's simple:
To je jednoduché:

```js
letourPlanetName = "Earth";
letjménoNašíPlanety = "Země";
```

Note, we could use a shorter name `planet`,but it might not be obvious what planet it refers to. It's nice to be more verbose. At least until the variable isNotTooLong.
Všimněte si, že bychom mohli použít kratší název `planeta`,ale pak by nemuselo být zřejmé, na kterou planetu se odkazuje. Je vhodné být výřečnější, aspoň dokud název proměnné neníPřílišDlouhý.

##The name of the current visitor
##Jméno aktuálního návštěvníka

```js
letcurrentUserName = "John";
letjménoAktuálníhoUživatele = "Jan";
```

Again, we could shorten that to `userName` if we know for sure that the user is current.
Opět bychom to mohli zkrátit na `jménoUživatele`, pokud máme jistotu, že jde o aktuálního uživatele.

Modern editors and autocomplete make long variable names easy to write. Don't save on them. A name with 3 words in it is fine.
V moderních editorech se dlouhé názvy proměnných snadno píší díky funkci automatického doplňování. Nešetřete na nich. Tříslovný název je zcela v pořádku.

And if your editordoes not have proper autocompletion, get [a new one](/code-editors).
A pokud váš editorneumí automatické doplňování, pořiďte si [nový](/code-editors).
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ importance: 3

---

#Giving the right name
#Správná volba názvu

1.Create a variable with the name of our planet. How would you name such a variable?
2.Create a variable to store the name of a current visitor to a website. How would you name that variable?
1.Vytvořte proměnnou s názvem naší planety. Jak byste takovou proměnnou pojmenovali?
2.Vytvořte proměnnou, v níž bude uloženo jméno aktuálního návštěvníka webové stránky. Jak byste takovou proměnnou pojmenovali?
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
We generally use upper case for constants that are "hard-coded". Or, in other words, when the value is known prior to execution and directly written into the code.
Obecně používáme velká písmena pro konstanty, které jsou „zakódovány natvrdo“. Jinými slovy, když je jejich hodnota známa ještě před spuštěním programu a je přímo uvedena v kódu.

In this code, `birthday` is exactly like that. So we could use the upper case for it.
V tomto kódu je to přesně případ proměnné `datumNarození`. Pro ni bychom tedy mohli použít velká písmena.

In contrast, `age` is evaluated in run-time. Today we have one age, a year after we'll have another one. It is constant in a sense that it does not change through the code execution. But it is a bit "less of a constant" than `birthday`:it is calculated, so we should keep the lower case for it.
Naproti tomu `věk` se počítá až při běhu programu. Dnes máme jeden věk, za rok budeme mít jiný. Je to konstanta v tom smyslu, že se její hodnota nezmění při provádění kódu, ale je „trochu méně konstantní“ než `datumNarození`:její hodnota je vypočítávána, takže pro ni bychom měli nechat malá písmena.
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,23 +2,23 @@ importance: 4

---

#Uppercase const?
#Konstanta velkými písmeny?

Examine the following code:
Prohlédněte si následující kód:

```js
constbirthday = '18.04.1982';
constdatumNarození = '18.04.1982';

constage =someCode(birthday);
constvěk =nějakýKód(datumNarození);
```

Here we have a constant `birthday` date and the `age` is calculated from `birthday` with the help of some code (it is not provided for shortness, and because details don't matter here).
Zde máme konstantu `datumNarození` a pomocí nějakého kódu se z této proměnné vypočítá `věk` (kód není pro stručnost uveden, na podrobnostech zde nezáleží).

Would it be right to use upper case for `birthday`? For `age`?Or even for both?
Bylo by správné použít pro název proměnné `datumNarození` velká písmena? A pro `věk`?Nebo dokonce pro obě?

```js
constBIRTHDAY = '18.04.1982'; //make uppercase?
constDATUM_NAROZENÍ = '18.04.1982'; //velkými písmeny?

constAGE =someCode(BIRTHDAY); //make uppercase?
constVĚK =nějakýKód(DATUM_NAROZENÍ); //velkými písmeny?
```

Loading

[8]ページ先頭

©2009-2025 Movatter.jp