Skip to content

Commit d937a22

Browse files
authored
Update article.md
- Change wording in first paragraph, and break out examples into numbered bullets. - Change some articles and words to make sentences clearer and more consistent.
1 parent 2d4e469 commit d937a22

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Variables
22

3-
Most of the time, a script needs to work with information. If it's an online-shop -- that's going to be the goods and a shopping cart. If it's a chat -- users, messages and so on.
3+
Most of the time, a JavaScript application needs to work with information. Here are 2 examples:
4+
1. An online-shop -- the information might include goods being sold and a shopping cart.
5+
2. A chat application -- the information might include users, messages, and much more.
46

5-
Variables are used to store the information.
7+
Variables are used to store this information.
68

79
[cut]
810

@@ -296,7 +298,7 @@ Please name the variables sensibly. Take time to think if needed.
296298
297299
Variable naming is one of the most important and complex skills in programming. A quick glance at variable names can reveal which code is written by a beginner and which by an experienced developer.
298300
299-
In a real project, most of the time is spent on modifying and extending the existing code base, rather than writing something completely separate from the scratch. And when we return to the code after some time of doing something else, it's much easier to find information that is well-labelled. Or, in other words, when the variables have good names.
301+
In a real project, most of the time is spent on modifying and extending the existing code base, rather than writing something completely separate from scratch. And when we return to the code after some time of doing something else, it's much easier to find information that is well-labelled. Or, in other words, when the variables have good names.
300302
301303
Please spend some time thinking about the right name for a variable before declaring it. That will repay you a lot.
302304
@@ -305,14 +307,14 @@ Some good-to-follow rules are:
305307
- Use human-readable names like `userName` or `shoppingCart`.
306308
- Stay away from abbreviations or short names like `a`, `b`, `c`, unless you really know what you're doing.
307309
- Make the name maximally descriptive and concise. Examples of bad names are `data` and `value`. Such a name says nothing. It is only ok to use them if it's exceptionally obvious from the context which data or value is meant.
308-
- Agree on terms within the team and in your own mind. If a site visitor is called a "user" then we should name related variables like `currentUser` or `newUser`, but not `currentVisitor` or a `newManInTown`.
310+
- 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 like `currentUser` or `newUser`, but not `currentVisitor` or a `newManInTown`.
309311
310312
Sounds simple? Indeed it is, but creating good descriptive-and-concise names in practice is not. Go for it.
311313
312314
```smart header="Reuse or create?"
313315
And the last note. There are some lazy programmers who, instead of declaring a new variable, tend to reuse the existing ones.
314316
315-
As the result, the variable is like a box where people throw different things without changing the sticker. What is inside it now? Who knows... We need to come closer and check.
317+
As a result, the variable is like a box where people throw different things without changing the sticker. What is inside it now? Who knows... We need to come closer and check.
316318
317319
Such a programmer saves a little bit on variable declaration, but loses ten times more on debugging the code.
318320

0 commit comments

Comments
 (0)