◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
2 changes: 1 addition & 1 deletion 1-js/01-getting-started/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Введення

Про мову JavaScript і робоче середовище, для розробки.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
In the code below, each line corresponds to the item in the task list.

```js run
let admin, name; // can declare two variables at once

name = "John";

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

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").
18 changes: 9 additions & 9 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 @@
First, the variable for the name of our planet.

That's simple:

```js
let ourPlanetName = "Earth";
```

Note, we could use a shorter name `planet`, but it might be not obvious what planet it refers to. It's nice to be more verbose. At least until the variable isNotTooLong.

Second, the name of the current visitor:

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

Again, we could shorten that to `userName` if we know for sure that the user is current.

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.

And if your editor does not have proper autocompletion, get [a new one](/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

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?
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.

In this code, `birthday` is exactly like that. So we could use the upper case for it.

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.
12 changes: 6 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,23 @@ importance: 4

---

# Uppercase const?

Examine the following code:

```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).

Would it be right to use upper case for `birthday`? For `age`? Or even for both?

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

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

Loading
Toggle all file notes Toggle all file annotations