Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1-js/02-first-steps/04-variables (#32)
* Transfer the existing translation Co-authored-by: maoxiaoke <thebigyellowbee@qq.com> resolve #4 * fix(variables): Adjust some contents * fix(variables): translate more tasks and solutions * 👌 fix: Adjust some words due to code review changes Signed-off-by: sqrtthree <imsqrtthree@gmail.com> * Update task.md * Update article.md * fix: Remove some spaces due to code review changes Signed-off-by: sqrtthree <imsqrtthree@gmail.com>
- Loading branch information
Showing
7 changed files
with
137 additions
and
138 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
1-js/02-first-steps/04-variables/1-hello-variables/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
1-js/02-first-steps/04-variables/2-declare-variables/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
注意,我们也可以用一个更短的名字 `planet`,但是它可能并不清楚它指的是什么行星。再啰嗦一点也是挺好的。至少直到这个变量“不太长”就行。 | ||
|
||
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. | ||
还有,如果我们的确知道用户就是当前的用户的话,我们可以使用更短的 `userName`。 | ||
|
||
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](/editors). | ||
如果你的编辑器没有合适的自动补全,换[一个新的吧](/editors)。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
1-js/02-first-steps/04-variables/3-uppercast-constant/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
在这个代码中 `birthday` 确信是这样的。因此我们可以使用大写。 | ||
|
||
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. | ||
在对照组中,`age` 是在运行时计算出的。今天我们有一个年龄,一年以后我们就会有另一个。它在某种意义上不会通过代码的执行而改变。但是相比 `birthday` 它是“少一些常量”的,它是计算出的,因此我们应该使用小写。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.