diff --git a/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/create-texture-by-adding-a-subtle-pattern-as-a-background-image.md b/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/create-texture-by-adding-a-subtle-pattern-as-a-background-image.md index 5770bfae9f..62a450b2ef 100644 --- a/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/create-texture-by-adding-a-subtle-pattern-as-a-background-image.md +++ b/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/create-texture-by-adding-a-subtle-pattern-as-a-background-image.md @@ -13,7 +13,7 @@ dashedName: create-texture-by-adding-a-subtle-pattern-as-a-background-image # --instructions-- -选取 `body` 元素,并设置整个页面的 `background` 为 url `https://i.imgur.com/MJAkxbh.png` 的图片。 +选取 `body` 元素,并设置整个页面的 `background` 为 url `https://cdn-media-1.freecodecamp.org/imgr/MJAkxbh.png` 的图片。 # --hints-- diff --git a/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/learn-about-tertiary-colors.md b/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/learn-about-tertiary-colors.md index 1abff66b10..9af21433ea 100644 --- a/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/learn-about-tertiary-colors.md +++ b/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/learn-about-tertiary-colors.md @@ -16,7 +16,7 @@ dashedName: learn-about-tertiary-colors 下面是使用分裂补色搭配法创建的三个颜色: -
颜色 | HEX 颜色码 |
---|---|
橙色 | #FF7D00 |
蓝绿色 | #00FFFF |
树莓红 | #FF007D |
颜色 | HEX 颜色码 |
---|---|
橙色 | #FF7F00 |
蓝绿色 | #00FFFF |
树莓红 | #FF007F |
Google was founded by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University.
+Google was founded by Larry Page and Sergey Brin while they were Ph.D. + students at Stanford University.
flex-start
:从 flex 容器的起始位置开始排列项目。 对行来说是把项目移至左边, 对于列是把项目移至顶部。 如未设置 justify-content
的值,那么这就是默认值。flex-end
:从 flex 容器的终止位置开始排列项目。 对行来说是把项目移至右边, 对于列是把项目移至底部。space-between
:项目间保留一定间距地沿主轴居中排列。 第一个和最后一个项目被放置在容器边沿。 例如,在行中第一个项目会紧贴着容器左边,最后一个项目会紧贴着容器右边,然后其他项目均匀排布。space-around
:与space-between
相似,但头尾两个项目不会紧贴容器边缘,所有项目之间的空间均匀排布。space-evenly
:头尾两个项目不会紧贴容器边缘,所有项目之间的空间均匀排布。\\
) in front of the quote.
+在 JavaScript 中,你可以通过在引号前面使用反斜杠(\\
)来转义引号。
`var sampleStr = "Alan said, \"Peter is learning JavaScript\".";`
-This signals to JavaScript that the following quote is not the end of the string, but should instead appear inside the string. So if you were to print this to the console, you would get:
+有了转义符号,JavaScript 就知道这个单引号或双引号并不是字符串的结尾,而是字符串内的字符。 所以,上面的字符串打印到控制台的结果为:
`Alan said, "Peter is learning JavaScript".`
# --instructions--
-Use backslashes to assign a string to the `myStr` variable so that if you were to print it to the console, you would see:
+使用反斜杠将一个字符串赋值给变量 `myStr`,打印到控制台,输出为:
`I am a "double quoted" string inside "double quotes".`
# --hints--
-You should use two double quotes (`"`) and four escaped double quotes (`\"`).
+你的代码中应该包含两个双引号(`"`)以及四个转义的双引号(`\"`)。
```js
assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2);
```
-Variable myStr should contain the string: `I am a "double quoted" string inside "double quotes".`
+变量 myStr 应该包含字符串 `I am a "double quoted" string inside "double quotes".`。
```js
assert(/I am a "double quoted" string inside "double quotes(\."|"\.)$/.test(myStr));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-with-javascript.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-with-javascript.md
index 42f91172df..7bdf262438 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-with-javascript.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-with-javascript.md
@@ -1,6 +1,6 @@
---
id: cf1111c1c12feddfaeb1bdef
-title: Generate Random Whole Numbers with JavaScript
+title: 使用 JavaScript 生成随机整数
challengeType: 1
videoUrl: 'https://scrimba.com/c/cRn6bfr'
forumTopicId: 18186
@@ -9,25 +9,25 @@ dashedName: generate-random-whole-numbers-with-javascript
# --description--
-It's great that we can generate random decimal numbers, but it's even more useful if we use it to generate random whole numbers.
+生成随机小数很棒,但随机数更有用的地方在于生成随机整数。
-Math.random()
to generate a random decimal.20
.Math.floor()
to round the number down to its nearest whole number.Math.random()
生成一个随机小数。20
。Math.floor()
向下取整,获得它最近的整数。路由:POST '/library'diff --git a/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/meet-the-node-console.md b/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/meet-the-node-console.md index e85e90bda7..799c65d21f 100644 --- a/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/meet-the-node-console.md +++ b/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/meet-the-node-console.md @@ -1,6 +1,6 @@ --- id: 587d7fb0367417b2b2512bed -title: Meet the Node console +title: 认识 Node 的控制台 challengeType: 2 forumTopicId: 301515 dashedName: meet-the-node-console @@ -8,21 +8,27 @@ dashedName: meet-the-node-console # --description-- -During the development process, it is important to be able to check what’s going on in your code. +可以采用下面的任意一种方式完成这些挑战: -Node is just a JavaScript environment. Like client side JavaScript, you can use the console to display useful debug information. On your local machine, you would see console output in a terminal. On Repl.it, a terminal is open in the right pane by default. +- 克隆 [这个 GitHub 仓库](https://github.com/freeCodeCamp/boilerplate-express/) 并在本地完成项目。 +- 使用 [Repl.it 上的初始化项目](https://repl.it/github/freeCodeCamp/boilerplate-express) 来完成项目。 +- 使用你选择的网站生成器来完成项目, 并确保包含了我们 GitHub 仓库的所有文件。 -We recommend to keep the terminal open while working at these challenges. By reading the output in the terminal, you can see any errors that may occur. +当完成本项目,请确认有一个正常运行的 demo 可以公开访问。 然后将 URL 提交到 `Solution Link` 中。 + +在开发过程中,能够随时看到代码的运行结果是非常重要的。 + +Node 只是一个 JavaScript 环境。 与客户端 JavaScript 一样,你可以使用控制台显示有用的调试信息。 在本地计算机上,你可以在终端中输出调试信息。 在 Repl.it 上,右侧边栏会默认打开一个终端。 + +我们建议在做这些挑战题时保持终端打开的状态。 通过这些终端的输出,你可能会发现这些错误的本质原因。 # --instructions-- -If you have not already done so, please read the instructions in [the introduction](/learn/apis-and-microservices/basic-node-and-express/) and start a new project on Repl.it using [this link](https://repl.it/github/freeCodeCamp/boilerplate-express). - -Modify the `myApp.js` file to log "Hello World" to the console. +修改 `myApp.js` 文件,在控制台打印出 “Hello World”。 # --hints-- -`"Hello World"` should be in the console +控制台应该输出 `"Hello World"` ```js (getUserInput) => diff --git a/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/serve-static-assets.md b/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/serve-static-assets.md index 44bf643496..cadc446f46 100644 --- a/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/serve-static-assets.md +++ b/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/serve-static-assets.md @@ -1,6 +1,6 @@ --- id: 587d7fb0367417b2b2512bf0 -title: Serve Static Assets +title: 提供静态资源服务 challengeType: 2 forumTopicId: 301518 dashedName: serve-static-assets @@ -8,21 +8,25 @@ dashedName: serve-static-assets # --description-- -An HTML server usually has one or more directories that are accessible by the user. You can place there the static assets needed by your application (stylesheets, scripts, images). In Express, you can put in place this functionality using the middleware `express.static(path)`, where the `path` parameter is the absolute path of the folder containing the assets. If you don’t know what middleware is... don’t worry, we will discuss in detail later. Basically, middleware are functions that intercept route handlers, adding some kind of information. A middleware needs to be mounted using the method `app.use(path, middlewareFunction)`. The first `path` argument is optional. If you don’t pass it, the middleware will be executed for all requests. +HTML 服务器通常有一个或多个用户可以访问的目录。 你可以将应用程序所需的静态资源 (样式表、脚本、图片) 放在那里。 + +在 Express 中可以使用中间件 `express.static(path)` 来设置此功能,它的参数 `path` 就是包含静态资源文件的绝对路径。 + +如果你不知道什么是中间件……别担心,我们将在后面详细讨论。 其实,中间件就是一个拦截路由处理方法并在里面添加一些信息的函数。 使用 `app.use(path, middlewareFunction)` 方法来加载一个中间件, 它的第一个参数 `path` 是可选的, 如果没设置第一个参数,那么所有的请求都会经过这个中间件处理。 # --instructions-- -Mount the `express.static()` middleware for all requests with `app.use()`. The absolute path to the assets folder is `__dirname + /public`. +使用 `app.use()` 为路径 `/public` 的请求安装 `express.static()` 中间件, 静态资源的绝对路径是 `__dirname + /public`。 -Now your app should be able to serve a CSS stylesheet. From outside, the public folder will appear mounted to the root directory. Your front-page should look a little better now! +现在应用应该能提供 CSS 样式表, 请注意, `/public/style.css` 文件被项目模板的 `/views/index.html` 引用, 首页应该更好看了。 # --hints-- -Your app should serve asset files from the `/public` directory +应用应该将资源文件从 `/public` 目录发送到 `/public` 路径 ```js (getUserInput) => - $.get(getUserInput('url') + '/style.css').then( + $.get(getUserInput('url') + '/public/style.css').then( (data) => { assert.match( data, diff --git a/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/use-body-parser-to-parse-post-requests.md b/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/use-body-parser-to-parse-post-requests.md index bf5ec23137..35e32af7d1 100644 --- a/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/use-body-parser-to-parse-post-requests.md +++ b/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/use-body-parser-to-parse-post-requests.md @@ -28,7 +28,7 @@ name=John+Doe&age=25 在 `package.json` 中安装 `body-parser` 模块, 然后在文件顶部 `require` 进来, 用变量 `bodyParser` 保存它。 通过中间件的 `bodyParser.urlencoded({extended: false})` 方法处理 URL 编码数据, 将调用上个方法返回的函数传给 `app.use()`, 中间件通常挂载在所有需要它的路由之前。 -**注意:**`extended=false`是一个告诉解析器使用经典编码的配置选项, 当使用它时,值只能是字符串或者数组, 拓展版本数据更加灵活,但稍逊于 JSON。 +**注意:**`extended=false` 是一个告诉解析器使用经典编码的配置选项, 当使用它时,值只能是字符串或者数组, 拓展版本数据更加灵活,但稍逊于 JSON。 # --hints-- diff --git a/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/use-the-.env-file.md b/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/use-the-.env-file.md index ad83674c7a..5ccd325db4 100644 --- a/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/use-the-.env-file.md +++ b/curriculum/challenges/chinese/05-apis-and-microservices/basic-node-and-express/use-the-.env-file.md @@ -1,6 +1,6 @@ --- id: 587d7fb1367417b2b2512bf2 -title: Use the .env File +title: 使用 .env 文件 challengeType: 2 forumTopicId: 301521 dashedName: use-the--env-file @@ -8,19 +8,19 @@ dashedName: use-the--env-file # --description-- -The `.env` file is a hidden file that is used to pass environment variables to your application. This file is secret, no one but you can access it, and it can be used to store data that you want to keep private or hidden. For example, you can store API keys from external services or your database URI. You can also use it to store configuration options. By setting configuration options, you can change the behavior of your application, without the need to rewrite some code. +`.env` 文件是一个用于将环境变量传给应用程序的隐藏文件, 这是一个除了开发者之外没人可以访问的私密文件,它可以用来存储你想保密或者隐藏的数据, 例如,它可以存储第三方服务的 API 密钥或者数据库 URI, 也可以使用它来存储配置选项, 通过设置配置选项,你可以改变应用程序的行为,而无需重写一些代码。 -The environment variables are accessible from the app as `process.env.VAR_NAME`. The `process.env` object is a global Node object, and variables are passed as strings. By convention, the variable names are all uppercase, with words separated by an underscore. The `.env` is a shell file, so you don’t need to wrap names or values in quotes. It is also important to note that there cannot be space around the equals sign when you are assigning values to your variables, e.g. `VAR_NAME=value`. Usually, you will put each variable definition on a separate line. +在应用程序中可以通过 `process.env.VAR_NAME` 访问到环境变量。 `process.env` 对象是 Node 程序中的一个全局对象,可以给这个变量传字符串。 习惯上,变量名全部大写,单词之间用下划线分隔。 `.env` 是一个 shell 文件,因此不需要用给变量名和值加引号。 还有一点需要注意,当你给变量赋值时等号两侧不能有空格,例如:`VAR_NAME=value`。 通常来讲,每一个变量定义会独占一行。 # --instructions-- -Let's add an environment variable as a configuration option. +添加一个环境变量作为配置选项。 -Store the variable `MESSAGE_STYLE=uppercase` in the `.env` file. Then tell the GET `/json` route handler that you created in the last challenge to transform the response object’s message to uppercase if `process.env.MESSAGE_STYLE` equals `uppercase`. The response object should become `{"message": "HELLO JSON"}`. +在项目根目录创建一个 `.env` 文件,并存储变量 `MESSAGE_STYLE=uppercase`。 当向 `/json` 发 GET 请求时,如果 `process.env.MESSAGE_STYLE` 的值为 `uppercase`,那么上一次挑战中的路由处理程序返回的对象的消息则应该大写, 即响应对象应该是 `{"message": "HELLO JSON"}`。 # --hints-- -The response of the endpoint `/json` should change according to the environment variable `MESSAGE_STYLE` +端口 `/json` 响应的值,应该随着环境变量 `MESSAGE_STYLE` 的变化而改变 ```js (getUserInput) => diff --git a/curriculum/challenges/chinese/05-apis-and-microservices/managing-packages-with-npm/how-to-use-package.json-the-core-of-any-node.js-project-or-npm-package.md b/curriculum/challenges/chinese/05-apis-and-microservices/managing-packages-with-npm/how-to-use-package.json-the-core-of-any-node.js-project-or-npm-package.md index 6222d50f0f..21e6711036 100644 --- a/curriculum/challenges/chinese/05-apis-and-microservices/managing-packages-with-npm/how-to-use-package.json-the-core-of-any-node.js-project-or-npm-package.md +++ b/curriculum/challenges/chinese/05-apis-and-microservices/managing-packages-with-npm/how-to-use-package.json-the-core-of-any-node.js-project-or-npm-package.md @@ -1,6 +1,6 @@ --- id: 587d7fb3367417b2b2512bfb -title: 'How to Use package.json, the Core of Any Node.js Project or npm Package' +title: '如何使用 package.json ——所有 Node.js 项目或 npm 包的核心' challengeType: 2 forumTopicId: 301528 dashedName: how-to-use-package-json-the-core-of-any-node-js-project-or-npm-package @@ -8,11 +8,19 @@ dashedName: how-to-use-package-json-the-core-of-any-node-js-project-or-npm-packa # --description-- -The `package.json` file is the center of any Node.js project or npm package. It stores information about your project, similar to how the <head> section of an HTML document describes the content of a webpage. It consists of a single JSON object where information is stored in key-value pairs. There are only two required fields; "name" and "version", but it’s good practice to provide additional information about your project that could be useful to future users or maintainers. +可以采用下面的任意一种方式完成这些挑战: -If you look at the file tree of your project, you will find the package.json file on the top level of the tree. This is the file that you will be improving in the next couple of challenges. +- 克隆 [GitHub repo](https://github.com/freeCodeCamp/boilerplate-npm/) 并在本地完成项目。 +- 使用 [Repl.it 上的初始化项目](https://repl.it/github/freeCodeCamp/boilerplate-npm) 来完成项目。 +- 使用你选择的网站生成器来完成项目, 并确保包含了我们 GitHub 仓库的所有文件。 -One of the most common pieces of information in this file is the `author` field. It specifies who created the project, and can consist of a string or an object with contact or other details. An object is recommended for bigger projects, but a simple string like the following example will do for this project. +当完成本项目,请确认有一个正常运行的 demo 可以公开访问。 然后将 URL 提交到 `Solution Link` 中。 此外,还可以将项目的源码提交到 `GitHub Link` 中。 + +`package.json` 文件是所有 Node.js 项目和 npm 包的枢纽, 和 HTML 文档中的 <head> 区域用来描述网页的配置信息(元数据)一样,它存储项目的相关信息。 它由单个 JSON 对象组成,并以键值对的形式存储项目信息, 且至少包含两个必填字段:“name”和“version”——但是最好提供有关项目的其他信息,这将对用户或者维护者有所帮助。 + +如果能找到项目的文件树,那么可以在文件树的最外层找到 package.json, 在接下来的几个挑战中将完善这个文件。 + +在这个文件中最常见的信息之一是 `author` 字段, 它说明了项目的创建者,它可以是字符串,也可以是带有联系人详细信息的对象。 对于较大的项目,建议使用对象;但是在我们的项目中,一个简单的字符串就够了,比如下面的例子: ```json "author": "Jane Doe", @@ -20,13 +28,13 @@ One of the most common pieces of information in this file is the `author` field. # --instructions-- -Add your name as the `author` of the project in the package.json file. +在项目的 package.json 文件的 `author` 键中添加你的名字。 -**Note:** Remember that you’re writing JSON, so all field names must use double-quotes (") and be separated with a comma (,). +**注意:** 正在修改的是一个 JSON,所有的字段名必须用双引号(")包裹,也必须用逗号(,)分割。 # --hints-- -package.json should have a valid "author" key +package.json 应该有一个有效的“author”键 ```js (getUserInput) => diff --git a/curriculum/challenges/chinese/05-apis-and-microservices/mongodb-and-mongoose/install-and-set-up-mongoose.md b/curriculum/challenges/chinese/05-apis-and-microservices/mongodb-and-mongoose/install-and-set-up-mongoose.md index 2067e13d90..85d63b0835 100644 --- a/curriculum/challenges/chinese/05-apis-and-microservices/mongodb-and-mongoose/install-and-set-up-mongoose.md +++ b/curriculum/challenges/chinese/05-apis-and-microservices/mongodb-and-mongoose/install-and-set-up-mongoose.md @@ -1,6 +1,6 @@ --- id: 587d7fb6367417b2b2512c06 -title: Install and Set Up Mongoose +title: 安装和设置 Mongoose challengeType: 2 forumTopicId: 301540 dashedName: install-and-set-up-mongoose @@ -8,11 +8,21 @@ dashedName: install-and-set-up-mongoose # --description-- -In this challenge, you will import the required projects, and connect to your Atlas database. +可以采用下面的任意一种方式完成这些挑战: + +- 克隆 [GitHub repo](https://github.com/freeCodeCamp/boilerplate-mongomongoose/) 并在本地完成项目。 +- 使用 [Repl.it 上的初始化项目](https://repl.it/github/freeCodeCamp/boilerplate-mongomongoose)来完成项目。 +- 使用你选择的网站生成器来完成项目, 并确保包含了我们 GitHub 仓库的所有文件。 + +当完成本项目,请确认有一个正常运行的 demo 可以公开访问。 然后将 URL 提交到 `Solution Link` 中。 + +在这个挑战中,你将建立一个 MongoDB Atlas 数据库并导入连接到它所需的软件包。 + +按照这篇教程在 MongoDB Atlas 创建一个托管数据库。 # --instructions-- -Add `mongodb` and `mongoose` to the project’s `package.json`. Then, require mongoose as `mongoose` in `myApp.js`. Store your MongoDB Atlas database URI in a private `.env` file as `MONGO_URI`. Surround the the URI with single or double quotes, and make sure no space exists between both the variable and the `=`, and the value and `=`. Connect to the database using the following syntax: +将 `mongodb` 和 `mongoose` 添加到项目的 `package.json` 文件中。 然后,在 `myApp.js` 文件中请求 `mongoose`。 创建一个 `.env` 文件,给它添加一个 `MONGO_URI` 变量。 变量的值为你的 MongoDB Atlas 数据库 URI。 应用单引号或双引号包裹 URI。请记住,环境变量 `=` 两边不能有空格。 例如,`MONGO_URI='VALUE'`。 完成后,使用下面的代码来连接数据库。 ```js mongoose.connect(
URL 编码的请求正文:userId=546&bookId=6754
req.body:{userId: '546', bookId: '6754'}