Skip to content

Commit ab1db04

Browse files
nakhodkinsmith558
andauthored
Fix grammar and typos (javascript-tutorial#3628)
Co-authored-by: Stanislav (Stanley) Modrak <44023416+smith558@users.noreply.github.com>
1 parent a7d351f commit ab1db04

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

1-js/02-first-steps/04-variables/article.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ In older scripts, you may also find another keyword: `var` instead of `let`:
8888
*!*var*/!* message = 'Hello';
8989
```
9090

91-
The `var` keyword is *almost* the same as `let`. It also declares a variable, but in a slightly different, "old-school" way.
91+
The `var` keyword is *almost* the same as `let`. It also declares a variable but in a slightly different, "old-school" way.
9292

93-
There are subtle differences between `let` and `var`, but they do not matter for us yet. We'll cover them in detail in the chapter <info:var>.
93+
There are subtle differences between `let` and `var`, but they do not matter to us yet. We'll cover them in detail in the chapter <info:var>.
9494
````
9595
9696
## A real-life analogy
9797
9898
We can easily grasp the concept of a "variable" if we imagine it as a "box" for data, with a uniquely-named sticker on it.
9999
100-
For instance, the variable `message` can be imagined as a box labeled `"message"` with the value `"Hello!"` in it:
100+
For instance, the variable `message` can be imagined as a box labelled `"message"` with the value `"Hello!"` in it:
101101
102102
![](variable.svg)
103103
@@ -198,14 +198,14 @@ Variables named `apple` and `APPLE` are two different variables.
198198
```
199199

200200
````smart header="Non-Latin letters are allowed, but not recommended"
201-
It is possible to use any language, including cyrillic letters, Chinese logograms and so on, like this:
201+
It is possible to use any language, including Cyrillic letters, Chinese logograms and so on, like this:
202202
203203
```js
204204
let имя = '...';
205205
let 我 = '...';
206206
```
207207
208-
Technically, there is no error here. Such names are allowed, but there is an international convention to use English in variable names. Even if we're writing a small script, it may have a long life ahead. People from other countries may need to read it some time.
208+
Technically, there is no error here. Such names are allowed, but there is an international convention to use English in variable names. Even if we're writing a small script, it may have a long life ahead. People from other countries may need to read it sometime.
209209
````
210210

211211
````warn header="Reserved names"
@@ -260,11 +260,11 @@ const myBirthday = '18.04.1982';
260260
myBirthday = '01.01.2001'; // error, can't reassign the constant!
261261
```
262262
263-
When a programmer is sure that a variable will never change, they can declare it with `const` to guarantee and clearly communicate that fact to everyone.
263+
When a programmer is sure that a variable will never change, they can declare it with `const` to guarantee and communicate that fact to everyone.
264264
265265
### Uppercase constants
266266
267-
There is a widespread practice to use constants as aliases for difficult-to-remember values that are known prior to execution.
267+
There is a widespread practice to use constants as aliases for difficult-to-remember values that are known before execution.
268268
269269
Such constants are named using capital letters and underscores.
270270
@@ -289,15 +289,15 @@ Benefits:
289289
290290
When should we use capitals for a constant and when should we name it normally? Let's make that clear.
291291
292-
Being a "constant" just means that a variable's value never changes. But there are constants that are known prior to execution (like a hexadecimal value for red) and there are constants that are *calculated* in run-time, during the execution, but do not change after their initial assignment.
292+
Being a "constant" just means that a variable's value never changes. But some constants are known before execution (like a hexadecimal value for red) and some constants are *calculated* in run-time, during the execution, but do not change after their initial assignment.
293293
294294
For instance:
295295
296296
```js
297297
const pageLoadTime = /* time taken by a webpage to load */;
298298
```
299299
300-
The value of `pageLoadTime` is not known prior to the page load, so it's named normally. But it's still a constant because it doesn't change after assignment.
300+
The value of `pageLoadTime` is not known before the page load, so it's named normally. But it's still a constant because it doesn't change after the assignment.
301301
302302
In other words, capital-named constants are only used as aliases for "hard-coded" values.
303303
@@ -307,18 +307,18 @@ Talking about variables, there's one more extremely important thing.
307307
308308
A variable name should have a clean, obvious meaning, describing the data that it stores.
309309
310-
Variable naming is one of the most important and complex skills in programming. A quick glance at variable names can reveal which code was written by a beginner versus an experienced developer.
310+
Variable naming is one of the most important and complex skills in programming. A glance at variable names can reveal which code was written by a beginner versus an experienced developer.
311311
312-
In a real project, most of the time is spent modifying and extending an existing code base rather than writing something completely separate from scratch. When we return to some code after doing something else for a while, it's much easier to find information that is well-labeled. Or, in other words, when the variables have good names.
312+
In a real project, most of the time is spent modifying and extending an existing code base rather than writing something completely separate from scratch. When we return to some code after doing something else for a while, it's much easier to find information that is well-labelled. Or, in other words, when the variables have good names.
313313
314314
Please spend time thinking about the right name for a variable before declaring it. Doing so will repay you handsomely.
315315
316316
Some good-to-follow rules are:
317317
318318
- Use human-readable names like `userName` or `shoppingCart`.
319-
- Stay away from abbreviations or short names like `a`, `b`, `c`, unless you really know what you're doing.
319+
- Stay away from abbreviations or short names like `a`, `b`, and `c`, unless you know what you're doing.
320320
- Make names maximally descriptive and concise. Examples of bad names are `data` and `value`. Such names say nothing. It's only okay to use them if the context of the code makes it exceptionally obvious which data or value the variable is referencing.
321-
- Agree on terms within your team and in your own mind. If a site visitor is called a "user" then we should name related variables `currentUser` or `newUser` instead of `currentVisitor` or `newManInTown`.
321+
- Agree on terms within your team and in your mind. If a site visitor is called a "user" then we should name related variables `currentUser` or `newUser` instead of `currentVisitor` or `newManInTown`.
322322
323323
Sounds simple? Indeed it is, but creating descriptive and concise variable names in practice is not. Go for it.
324324

0 commit comments

Comments
 (0)