Skip to content

Variables #151

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ed3dc39
variables
Alexandra2888 Dec 1, 2022
043d333
fix a typo
Alexandra2888 Dec 1, 2022
c42701b
Apply suggestions from code review
bogdanbacosca Dec 2, 2022
0b41a45
fix-1-solution.md
Alexandra2888 Dec 2, 2022
46fdd9a
fix 3-task.md
Alexandra2888 Dec 2, 2022
070962a
fix article.md
Alexandra2888 Dec 2, 2022
5a7f0a0
fix 3-task.md
Alexandra2888 Dec 2, 2022
f41283a
variables
Alexandra2888 Dec 2, 2022
a1b16e3
1-solution.md
Alexandra2888 Dec 2, 2022
d8f9162
update 1-solution.md per last request
Alexandra2888 Dec 2, 2022
e37acbc
update article.md
Alexandra2888 Dec 2, 2022
425a827
fix line in article.md
Alexandra2888 Dec 2, 2022
3ad9976
fix some lines and typos on article.md
Alexandra2888 Dec 2, 2022
0e33558
fix lines in article.md
Alexandra2888 Dec 2, 2022
7dc6241
fix line in article.md
Alexandra2888 Dec 2, 2022
efad982
Merge branch 'master' into Variables
Alexandra2888 Dec 2, 2022
e44643d
updated
bogdanbacosca Dec 3, 2022
8af2879
update
bogdanbacosca Dec 3, 2022
206cfbb
declare variables
Alexandra2888 Dec 3, 2022
80b8887
Merge branch 'Variables' of https://github.com/Alexandra2888/ro.javas…
Alexandra2888 Dec 3, 2022
947b6d3
uppercast-constant
Alexandra2888 Dec 3, 2022
cea67df
article.md
Alexandra2888 Dec 3, 2022
80bea6d
article.md
Alexandra2888 Dec 3, 2022
7fe85d0
article.md
Alexandra2888 Dec 3, 2022
215e676
article.md
Alexandra2888 Dec 5, 2022
6d5f956
article.md
Alexandra2888 Dec 5, 2022
e60bf8f
svg
Alexandra2888 Dec 5, 2022
3609555
final polish
bogdanbacosca Dec 6, 2022
0832fdf
minor fix
bogdanbacosca Dec 6, 2022
13da2ca
sync main
bogdanbacosca Dec 6, 2022
e9dcaf3
minor improvement
bogdanbacosca Dec 6, 2022
873c53f
minor update
bogdanbacosca Dec 6, 2022
14c9aa4
minor update
bogdanbacosca Dec 6, 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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
In the code below, each line corresponds to the item in the task list.
În codul de mai jos, fiecare linie corespunde cu articolul din lista de sarcini.

```js run
let admin, name; // can declare two variables at once
let admin, name; // putem declara două variabile deodată

name = "John";

Expand All @@ -10,3 +10,4 @@ admin = name;
alert( admin ); // "John"
```


10 changes: 5 additions & 5 deletions 1-js/02-first-steps/04-variables/1-hello-variables/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ importance: 2

---

# Working with variables
# Lucrând cu variabile

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. Declară două variabile: `admin` și `name`.
2. Atribuie valoarea `"John"` la `name`.
3. Copiază valoarea de la `name` la `admin`.
4. Arată valoarea lui `admin` folosind `alert` (trebuie să iasă "John").
16 changes: 8 additions & 8 deletions 1-js/02-first-steps/04-variables/2-declare-variables/solution.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
## The variable for our planet
## Variabila pentru planeta noastră

That's simple:
Este simplu:

```js
let ourPlanetName = "Earth";
let ourPlanetName = "Pământ";
```

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.
Notează, am putea folosi un nume mai scurt decât `planet`, dar s-ar putea să nu fie evident la ce planetă se referă. E frumos să fim mai verbali. Cel puțin până când variabila nuEstePreaLungă.

## The name of the current visitor
## Numele vizitatorului curent

```js
let currentUserName = "John";
```

Again, we could shorten that to `userName` if we know for sure that the user is current.
Din nou, am putea scurta acest `userName` dacă știm sigur că acest utilizator este unul curent.

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.
Editoarele moderne și autocompletarea fac numele lungi de variabile ușor de scris. Nu economisi la ele. Un nume care conține trei cuvinte este în regulă.

And if your editor does not have proper autocompletion, get [a new one](/code-editors).
Și dacă editorul tău nu are autocompletare corectă, ia [unul nou](/code-editors).
6 changes: 3 additions & 3 deletions 1-js/02-first-steps/04-variables/2-declare-variables/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ importance: 3

---

# Giving the right name
# Dând numele corect

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. Crează o variabilă cu numele planetei noastre. Cum ai numi o astfel de variabilă?
2. Crează o variabilă care să stocheze numele unui vizitator curent al unui website. Cum ai numi o astfel de variabilă?
Original file line number Diff line number Diff 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.
În general folosim majuscule pentru constante care sunt "hard-coded". Sau, în alte cuvinte, când valoarea este știută înainte de execuție și este scrisă direct în cod.

In this code, `birthday` is exactly like that. So we could use the upper case for it.
În acest cod, `birthday` este exact la fel. Deci am putea folosi majuscule pentru el.

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.
În contrast, `age` evaluat în timpul execuției. Astăzi avem o vârstă, peste un an vom avea alta. Este constantă în sensul că nu se schimbă pe parcursul execuției codului. Dar este un pic "mai puțin constantă" decât `birthday`: este calculată, deci ar trebui să păstrăm minuscule pentru aceasta.
14 changes: 8 additions & 6 deletions 1-js/02-first-steps/04-variables/3-uppercast-constant/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@ importance: 4

---

# Uppercase const?
# Const cu majuscule?

Examine the following code:
Examinează următorul cod:

```js
const birthday = '18.04.1982';

const age = someCode(birthday);
```

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).
Aici avem o constantă `birthday` pentru dată, și de asemenea constanta `age`.

Would it be right to use upper case for `birthday`? For `age`? Or even for both?
`age` este calculată din `birthday` folosind `someCode()`, ceea ce înseamnă un apel de funcție pe care nu l-am explicat încă (o vom face în curând!), dar detaliile nu contează aici, ideea este că `age` este calculată cumva pe baza `birthday`.

Ar fi corect să folosim majuscule pentru `birthday`? Pentru `age`? Sau chiar pentru ambele?

```js
const BIRTHDAY = '18.04.1982'; // make uppercase?
const BIRTHDAY = '18.04.1982'; // facem BIRTHDAY cu majuscule?

const AGE = someCode(BIRTHDAY); // make uppercase?
const AGE = someCode(BIRTHDAY); // facem AGE cu majuscule?
```

Loading