chore(i8n,curriculum): processed translations (#41551)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
This commit is contained in:
@@ -1,68 +1,68 @@
|
||||
---
|
||||
id: 5e601c0d5ac9d0ecd8b94afe
|
||||
title: American British Translator
|
||||
title: 美式英语英式英语转换器
|
||||
challengeType: 4
|
||||
dashedName: american-british-translator
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
Build a full stack JavaScript app that is functionally similar to this: <https://american-british-translator.freecodecamp.rocks/>. Working on this project will involve you writing your code using one of the following methods:
|
||||
构建一个 JavaScript 的全栈应用,在功能上与这个应用相似:<https://american-british-translator.freecodecamp.rocks/>。 可以采用下面的任意一种方式完成这个挑战:
|
||||
|
||||
- Clone [this GitHub repo](https://github.com/freeCodeCamp/boilerplate-project-american-british-english-translator/) and complete your project locally.
|
||||
- Use [our repl.it starter project](https://repl.it/github/freeCodeCamp/boilerplate-project-american-british-english-translator) to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
- 克隆 [这个 GitHub 仓库](https://github.com/freeCodeCamp/boilerplate-project-american-british-english-translator/) 并在本地完成项目。
|
||||
- 使用 [repl.it 上的初始化项目](https://repl.it/github/freeCodeCamp/boilerplate-project-american-british-english-translator) 来完成项目。
|
||||
- 使用您选择的站点生成器来完成项目。 并确保包含了我们 GitHub 仓库的所有文件。
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
当完成本项目,请确认有一个可以公开访问的正常运行 demo 。 然后将 URL 提交到 `Solution Link` 中。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
|
||||
# --instructions--
|
||||
|
||||
- All logic can go into `/components/translator.js`
|
||||
- Complete the `/api/translate` route in `/routes/api.js`
|
||||
- Create all of the unit/functional tests in `tests/1_unit-tests.js` and `tests/2_functional-tests.js`
|
||||
- See the JavaScript files in `/components` for the different spelling and terms your application should translate
|
||||
- To run the tests on Repl.it, set `NODE_ENV` to `test` without quotes in the `.env` file
|
||||
- To run the tests in the console, use the command `npm run test`. To open the Repl.it console, press Ctrl+Shift+P (Cmd if on a Mac) and type "open shell"
|
||||
- 所有逻辑都可以进入 `/components/translator.js`
|
||||
- 在 `/routes/api.js` 中完成 `/api/translate` 路由
|
||||
- 在 `tests/1_unit-tests.js` 和 `tests/2_functional-tests.js` 中创建所有 unit/functional 测试
|
||||
- 查看 `/components` 中的 JavaScript 文件以获取应用程序应该翻译的条款以及不同的拼写
|
||||
- 在 `.env` 文件中将 `NODE_ENV` 设置为 `test`(没有引号),运行 Repl.it 上的测试。
|
||||
- 使用 `npm run test` 命令,在 console 运行测试。 按 Ctrl+Shift+P (在 Mac 上是 Cmd+Shift+P) 并输入"open shell",打开 Repl.it 控制台。
|
||||
|
||||
Write the following tests in `tests/1_unit-tests.js`:
|
||||
在 `tests/1_unit-tests.js` 中写下以下测试:
|
||||
|
||||
- Translate `Mangoes are my favorite fruit.` to British English
|
||||
- Translate `I ate yogurt for breakfast.` to British English
|
||||
- Translate `We had a party at my friend's condo.` to British English
|
||||
- Translate `Can you toss this in the trashcan for me?` to British English
|
||||
- Translate `The parking lot was full.` to British English
|
||||
- Translate `Like a high tech Rube Goldberg machine.` to British English
|
||||
- Translate `To play hooky means to skip class or work.` to British English
|
||||
- Translate `No Mr. Bond, I expect you to die.` to British English
|
||||
- Translate `Dr. Grosh will see you now.` to British English
|
||||
- Translate `Lunch is at 12:15 today.` to British English
|
||||
- Translate `We watched the footie match for a while.` to American English
|
||||
- Translate `Paracetamol takes up to an hour to work.` to American English
|
||||
- Translate `First, caramelise the onions.` to American English
|
||||
- Translate `I spent the bank holiday at the funfair.` to American English
|
||||
- Translate `I had a bicky then went to the chippy.` to American English
|
||||
- Translate `I've just got bits and bobs in my bum bag.` to American English
|
||||
- Translate `The car boot sale at Boxted Airfield was called off.` to American English
|
||||
- Translate `Have you met Mrs Kalyani?` to American English
|
||||
- Translate `Prof Joyner of King's College, London.` to American English
|
||||
- Translate `Tea time is usually around 4 or 4.30.` to American English
|
||||
- Highlight translation in `Mangoes are my favorite fruit.`
|
||||
- Highlight translation in `I ate yogurt for breakfast.`
|
||||
- Highlight translation in `We watched the footie match for a while.`
|
||||
- Highlight translation in `Paracetamol takes up to an hour to work.`
|
||||
- 将 `Mangoes are my favorite fruit.` 转换成英式英语。
|
||||
- 将 `I ate yogurt for breakfast.` 转换成英式英语。
|
||||
- 将 `We had a party at my friend's condo.` 转换成英式英语。
|
||||
- 将 `Can you toss this in the trashcan for me?` 转换成英式英语。
|
||||
- 将 `The parking lot was full.` 转换成英式英语。
|
||||
- 将 `Like a high tech Rube Goldberg machine.` 转换成英式英语。
|
||||
- 将 `To play hooky means to skip class or work.` 转换成英式英语。
|
||||
- 将 `No Mr. Bond, I expect you to die.` 转换成英式英语。
|
||||
- 将 `Dr. Grosh will see you now.` 转换成英式英语。
|
||||
- 将 `Lunch is at 12:15 today.` 转换成英式英语。
|
||||
- 将 `We watched the footie match for a while.` 转换成美式英语。
|
||||
- 将 `Paracetamol takes up to an hour to work.` 转换成美式英语。
|
||||
- 将 `First, caramelise the onions.` 转换成美式英语。
|
||||
- 将 `I spent the bank holiday at the funfair.` 转换成美式英语。
|
||||
- 将 `I had a bicky then went to the chippy.` 转换成美式英语。
|
||||
- 将 `I've just got bits and bobs in my bum bag.` 转换成美式英语。
|
||||
- 将 `The car boot sale at Boxted Airfield was called off.` 转换成美式英语。
|
||||
- 将 `Have you met Mrs Kalyani?` 转换成美式英语。
|
||||
- 将 `Prof Joyner of King's College, London.` 转换成美式英语。
|
||||
- 将 `Tea time is usually around 4 or 4.30.` 转换成美式英语。
|
||||
- 将 `Mangoes are my favorite fruit.` 里的转换高亮。
|
||||
- 高亮 `I ate yogurt for breakfast.` 里的转换。
|
||||
- 高亮 `We watched the footie match for a while.` 里的转换。
|
||||
- 高亮 `Paracetamol takes up to an hour to work.` 里的转换。
|
||||
|
||||
Write the following tests in `tests/2_functional-tests.js`:
|
||||
在 `tests/2_functional-tests.js` 中写下以下测试:
|
||||
|
||||
- Translation with text and locale fields: POST request to `/api/translate`
|
||||
- Translation with text and invalid locale field: POST request to `/api/translate`
|
||||
- Translation with missing text field: POST request to `/api/translate`
|
||||
- Translation with missing locale field: POST request to `/api/translate`
|
||||
- Translation with empty text: POST request to `/api/translate`
|
||||
- Translation with text that needs no translation: POST request to `/api/translate`
|
||||
- 翻译文本字段和本地化字段: POST 请求到 `/api/translate`
|
||||
- 翻译文本字段和无效的本地化字段: POST 请求到 `/api/translate`
|
||||
- 翻译缺失的文本字段: POST 请求到 `/api/translate`
|
||||
- 翻译缺失的本地化字段: POST 请求到 `/api/translate`
|
||||
- 翻译空的文本: POST 请求到 `/api/translate`
|
||||
- 翻译无需翻译的文本: POST 请求到 `/api/translate`
|
||||
|
||||
# --hints--
|
||||
|
||||
I can provide my own project, not the example URL.
|
||||
我可以提供我自己的项目,而不是示例 URL。
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -74,7 +74,7 @@ I can provide my own project, not the example URL.
|
||||
};
|
||||
```
|
||||
|
||||
You can `POST` to `/api/translate` with a body containing `text` with the text to translate and `locale` with either `american-to-british` or `british-to-american`. The returned object should contain the submitted `text` and `translation` with the translated text.
|
||||
可以向 `/api/translate` 发送 `POST` 请求,对请求体内的 `text` 文本进行翻译, `locale` 字段可以是 `american-to-british` 或 `british-to-american`。 返回的对象应该包含提交的 `text` 以及翻译的文本 `translation`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -102,7 +102,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
The `/api/translate` route should handle the way time is written in American and British English. For example, ten thirty is written as "10.30" in British English and "10:30" in American English. The `span` element should wrap the entire time string, i.e. `<span class="highlight">10:30</span>`.
|
||||
`/api/translate` 路由应该可以处理用英美方式英语写的时间。 例如,十点半英式英语写为“10.30”,而美式英语写为“10:30”。 `span` 元素应该包裹整个时间字符串,即 `<span class="highlight">10:30</span>`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -129,7 +129,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
The `/api/translate` route should also handle the way titles/honorifics are abbreviated in American and British English. For example, Doctor Wright is abbreviated as "Dr Wright" in British English and "Dr. Wright" in American English. See `/public/american-to-british-titles.js` for the different titles your application should handle.
|
||||
`/api/translate` 路由也应该处理美式英语和英式英语中头衔/尊称的缩写方式。 例如,Doctor Wright 在英式英语中缩写为 “Dr Wright”,在美式英语中缩写为 “Dr. Wright"”。 查看 `/public/american-to-british-titles.js` 了应用程序应该处理的不同的头衔。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -156,7 +156,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
Wrap any translated spelling or terms with `<span class="highlight">...</span>` tags so they appear in green.
|
||||
将任何翻译过的拼写或条目放在 `<span class="highlight">...</span>` 标签内以使其显示为绿色。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -184,7 +184,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If one or more of the required fields is missing, return `{ error: 'Required field(s) missing' }`.
|
||||
如果缺少一个或多个必填字段,返回 `{ error: 'Required field(s) missing' }`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -205,7 +205,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If `text` is empty, return `{ error: 'No text to translate' }`
|
||||
如果 `text` 为空,返回 `{ error: 'No text to translate' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -226,7 +226,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If `locale` does not match one of the two specified locales, return `{ error: 'Invalid value for locale field' }`.
|
||||
如果 `locale` 与两个指定的 locales 都不匹配,返回 `{ error: 'Invalid value for locale field' }`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -248,7 +248,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If `text` requires no translation, return `"Everything looks good to me!"` for the `translation` value.
|
||||
如果 `text` 不需要翻译,返回的 `translation` 值为`"Everything looks good to me!"`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -275,7 +275,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
All 24 unit tests are complete and passing. See `/tests/1_unit-tests.js` for the expected behavior you should write tests for.
|
||||
所有 24 个单元的测试都已完成并通过。 请参阅 `/tests/1_unit-tests.js` 来了解你应该写的测试的预期行为。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -300,7 +300,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
All 6 functional tests are complete and passing. See `/tests/2_functional-tests.js` for the functionality you should write tests for.
|
||||
所有 6 项功能测试都已完成并通过。 请参阅 `/tests/2_functional-tests.js` 来了解你应该写的测试的功能。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d8249367417b2b2512c42
|
||||
title: Issue Tracker
|
||||
title: 问题跟踪器
|
||||
challengeType: 4
|
||||
forumTopicId: 301569
|
||||
dashedName: issue-tracker
|
||||
@@ -8,42 +8,42 @@ dashedName: issue-tracker
|
||||
|
||||
# --description--
|
||||
|
||||
Build a full stack JavaScript app that is functionally similar to this: <https://issue-tracker.freecodecamp.rocks/>. Working on this project will involve you writing your code using one of the following methods:
|
||||
构建一个 JavaScript 的全栈应用,在功能上与这个应用相似: <https://issue-tracker.freecodecamp.rocks/>。 可以采用下面的任意一种方式完成这个挑战:
|
||||
|
||||
- Clone [this GitHub repo](https://github.com/freeCodeCamp/boilerplate-project-issuetracker/) and complete your project locally.
|
||||
- Use [this repl.it starter project](https://repl.it/github/freeCodeCamp/boilerplate-project-issuetracker) to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
- 克隆 [GitHub 仓库](https://github.com/freeCodeCamp/boilerplate-project-issuetracker/) 并在本地完成你的项目。
|
||||
- 使用 [repl.it 上的初始化项目](https://repl.it/github/freeCodeCamp/boilerplate-project-issuetracker) 来完成项目。
|
||||
- 使用一个你喜欢的站点生成器来完成项目。 需要确定包含了我们 GitHub 仓库的所有文件。
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 框中提交你的项目 URL。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
|
||||
# --instructions--
|
||||
|
||||
- Complete the necessary routes in `/routes/api.js`
|
||||
- Create all of the functional tests in `tests/2_functional-tests.js`
|
||||
- Copy the `sample.env` file to `.env` and set the variables appropriately
|
||||
- To run the tests uncomment `NODE_ENV=test` in your `.env` file
|
||||
- To run the tests in the console, use the command `npm run test`. To open the Repl.it console, press Ctrl+Shift+P (Cmd if on a Mac) and type "open shell"
|
||||
- 在 `/routes/api.js` 中完成必要的路由
|
||||
- 在 `tests/2_functional-tests.js` 中创建所有的功能测试
|
||||
- 复制 `sample.env` 文件到 `.env` 并按需设置变量
|
||||
- 要运行测试,在 `.env` 文件中取消注释 `NODE_ENV=test`
|
||||
- 使用 `npm run test` 命令,在 console 运行测试。 按 Ctrl+Shift+P (在 Mac 上是 Cmd+Shift+P) 并输入"open shell",打开 Repl.it 控制台。
|
||||
|
||||
Write the following tests in `tests/2_functional-tests.js`:
|
||||
在 `tests/2_functional-tests.js` 中编写下以下测试:
|
||||
|
||||
- Create an issue with every field: POST request to `/api/issues/{project}`
|
||||
- Create an issue with only required fields: POST request to `/api/issues/{project}`
|
||||
- Create an issue with missing required fields: POST request to `/api/issues/{project}`
|
||||
- View issues on a project: GET request to `/api/issues/{project}`
|
||||
- View issues on a project with one filter: GET request to `/api/issues/{project}`
|
||||
- View issues on a project with multiple filters: GET request to `/api/issues/{project}`
|
||||
- Update one field on an issue: PUT request to `/api/issues/{project}`
|
||||
- Update multiple fields on an issue: PUT request to `/api/issues/{project}`
|
||||
- Update an issue with missing `_id`: PUT request to `/api/issues/{project}`
|
||||
- Update an issue with no fields to update: PUT request to `/api/issues/{project}`
|
||||
- Update an issue with an invalid `_id`: PUT request to `/api/issues/{project}`
|
||||
- Delete an issue: DELETE request to `/api/issues/{project}`
|
||||
- Delete an issue with an invalid `_id`: DELETE request to `/api/issues/{project}`
|
||||
- Delete an issue with missing `_id`: DELETE request to `/api/issues/{project}`
|
||||
- 用所有字段创建 issue:POST 请求到 `/api/issues/{project}`
|
||||
- 用必填字段创建 issue:POST 请求到 `/api/issues/{project}`
|
||||
- 用缺失必填字段创建 issue:POST 请求到 `/api/issues/{project}`
|
||||
- 查看 project 里的 issue:GET 请求到 `/api/issues/{project}`
|
||||
- 用 filter 过滤 project 里的 issue:GET 请求到 `/api/issues/{project}`
|
||||
- 用多个 filter 过滤 project 里的 issue:GET 请求到 `/api/issues/{project}`
|
||||
- 更新 issue 里的一个字段:PUT 请求到 `/api/issues/{project}`
|
||||
- 更新 issue 里的多个字段:PUT 请求到 `/api/issues/{project}`
|
||||
- 在缺少 `_id` 字段的情况下更新 issue: PUT 请求到 `/api/issues/{project}`
|
||||
- 在没有字段更新的情况下调用更新:PUT 请求到 `/api/issues/{project}`
|
||||
- 传入一个无效的的 `_id` 来调用更新:PUT 请求到 `/api/issues/{project}`
|
||||
- 删除一个 issue:DELETE 请求到 `/api/issues/{project}`
|
||||
- 传入一个无效的的 `_id` 来调用删除:DELETE 请求到 `/api/issues/{project}`
|
||||
- 在缺失 `_id` 的情况下来调用删除:DELETE 请求到 `/api/issues/{project}`
|
||||
|
||||
# --hints--
|
||||
|
||||
You can provide your own project, not the example URL.
|
||||
提交自己的项目,而不是示例的 URL。
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -51,7 +51,7 @@ You can provide your own project, not the example URL.
|
||||
};
|
||||
```
|
||||
|
||||
You can send a `POST` request to `/api/issues/{projectname}` with form data containing the required fields `issue_title`, `issue_text`, `created_by`, and optionally `assigned_to` and `status_text`.
|
||||
可以发送 `POST` 请求到 `/api/issues/{projectname}`,表单数据包含必填字段 `issue_title`、`issue_text`、`created_by` 和可选字段 `assigned_to` 以及 `status_text`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -73,7 +73,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
The `POST` request to `/api/issues/{projectname}` will return the created object, and must include all of the submitted fields. Excluded optional fields will be returned as empty strings. Additionally, include `created_on` (date/time), `updated_on` (date/time), `open` (boolean, `true` for open - default value, `false` for closed), and `_id`.
|
||||
`POST` 请求到 `/api/issues/{projectname}` 将返回创建的对象,必须包含所有提交的全部字段。 如果没有填选填字段将作为空字符串返回. 此外,包含 `created_on` (日期/时间)、 `updated_on` (日期/时间)、 `open` (布尔型) `true` 用于打开 - 默认值, `false` 用于关闭, `_id`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -107,7 +107,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If you send a `POST` request to `/api/issues/{projectname}` without the required fields, returned will be the error `{ error: 'required field(s) missing' }`
|
||||
如果发送一个 `POST` 请求到 `/api/issues/{projectname}` 且缺少必填字段,会返回错误 `{ error: 'required field(s) missing' }`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -125,7 +125,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
You can send a `GET` request to `/api/issues/{projectname}` for an array of all issues for that specific `projectname`, with all the fields present for each issue.
|
||||
可以发送 `GET` 请求到 `/api/issues/{projectname}` 请求所有指定 `projectname` 的 issues 数组,会展示每个 issue 的所有字段。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -172,7 +172,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
You can send a `GET` request to `/api/issues/{projectname}` and filter the request by also passing along any field and value as a URL query (ie. `/api/issues/{project}?open=false`). You can pass one or more field/value pairs at once.
|
||||
可以发送 `GET` 请求到 `/api/issues/{projectname}` 通过 URL 查询传入字段名和值过滤请求(如, `/api/issues/{project}?open=false`)。 你可以一次通过一个或多个字段/值对。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -213,7 +213,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
You can send a `PUT` request to `/api/issues/{projectname}` with an `_id` and one or more fields to update. On success, the `updated_on` field should be updated, and returned should be `{ result: 'successfully updated', '_id': _id }`.
|
||||
你可以发送一个 `PUT` 请求到 `/api/issues/{projectname}` 带有一个 `_id` 以及一个或多个字段进行更新。 成功后, `updated_on` field 应该被更新,返回的应该是 `{ result: 'successfully updated', '_id': _id }`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -248,7 +248,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
When the `PUT` request sent to `/api/issues/{projectname}` does not include an `_id`, the return value is `{ error: 'missing _id' }`.
|
||||
当 `PUT` 请求发送给 `/api/issues/{projectname}` 的请求体不包含 `_id` 时应返回`{ error: 'missing _id' }`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -264,7 +264,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
When the `PUT` request sent to `/api/issues/{projectname}` does not include update fields, the return value is `{ error: 'no update field(s) sent', '_id': _id }`. On any other error, the return value is `{ error: 'could not update', '_id': _id }`.
|
||||
当 `PUT` 请求发送给 `/api/issues/{projectname}` 的请求体不包含任何更新的字段,应返回 `{ error: 'no update field(s) sent', '_id': _id }`。 在任何其他错误,应返回 `{ error: 'could not update', '_id': _id }`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -294,7 +294,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
You can send a `DELETE` request to `/api/issues/{projectname}` with an `_id` to delete an issue. If no `_id` is sent, the return value is `{ error: 'missing _id' }`. On success, the return value is `{ result: 'successfully deleted', '_id': _id }`. On failure, the return value is `{ error: 'could not delete', '_id': _id }`.
|
||||
你可以发送一个 `DELETE` 请求到 `/api/issues/{projectname}` 带有一个 `_id` 来删除 issue。 如果没有发送 `_id` ,返回值为 `{ error: 'missing _id' }`。 成功后,返回值为 `{ result: 'successfully deleted', '_id': _id }`。 失败时,返回值为 `{ error: 'could not delete', '_id': _id }`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -336,7 +336,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
All 14 functional tests are complete and passing.
|
||||
所有 14 项功能测试都已完成并通过。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d8249367417b2b2512c41
|
||||
title: Metric-Imperial Converter
|
||||
title: 公制 - 英制转换器
|
||||
challengeType: 4
|
||||
forumTopicId: 301570
|
||||
dashedName: metric-imperial-converter
|
||||
@@ -8,52 +8,52 @@ dashedName: metric-imperial-converter
|
||||
|
||||
# --description--
|
||||
|
||||
Build a full stack JavaScript app that is functionally similar to this: <https://metric-imperial-converter.freecodecamp.rocks/>. Working on this project will involve you writing your code using one of the following methods:
|
||||
构建一个 JavaScript 的全栈应用,在功能上与这个应用相似:<https://metric-imperial-converter.freecodecamp.rocks/>。 可以采用下面的任意一种方式完成这个挑战:
|
||||
|
||||
- Clone [this GitHub repo](https://github.com/freeCodeCamp/boilerplate-project-metricimpconverter/) and complete your project locally.
|
||||
- Use [our repl.it starter project](https://repl.it/github/freeCodeCamp/boilerplate-project-metricimpconverter) to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
- 克隆 [GitHub 仓库](https://github.com/freeCodeCamp/boilerplate-project-metricimpconverter/) 并在本地完成你的项目。
|
||||
- 使用 [repl.it 上的初始化项目](https://repl.it/github/freeCodeCamp/boilerplate-project-metricimpconverter) 来完成项目。
|
||||
- 使用一个你喜欢的站点生成器来完成项目。 需要确定包含了我们 GitHub 仓库的所有文件。
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 框中提交你的项目 URL。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
|
||||
# --instructions--
|
||||
|
||||
- Complete the necessary conversion logic in `/controllers/convertHandler.js`
|
||||
- Complete the necessary routes in `/routes/api.js`
|
||||
- Copy the `sample.env` file to `.env` and set the variables appropriately
|
||||
- To run the tests uncomment `NODE_ENV=test` in your `.env` file
|
||||
- To run the tests in the console, use the command `npm run test`. To open the Repl.it console, press Ctrl+Shift+P (Cmd if on a Mac) and type "open shell"
|
||||
- 在 `/controllers/convertHandler.js` 中完成必要的转换逻辑
|
||||
- 在 `/routes/api.js` 中完成必要的路由
|
||||
- 复制 `sample.env` 文件到 `.env` 并按需设置变量
|
||||
- 在 `.env` 文件中取消注释 `NODE_ENV=test` 来运行测试
|
||||
- 使用 `npm run test` 命令在 console 中运行测试。 按 Ctrl+Shift+P (在 Mac 上是 Cmd+Shift+P) 并输入"open shell",打开 Repl.it 控制台。
|
||||
|
||||
Write the following tests in `tests/1_unit-tests.js`:
|
||||
在 `tests/1_unit-tests.js` 中写下以下测试:
|
||||
|
||||
- `convertHandler` should correctly read a whole number input.
|
||||
- `convertHandler` should correctly read a decimal number input.
|
||||
- `convertHandler` should correctly read a fractional input.
|
||||
- `convertHandler` should correctly read a fractional input with a decimal.
|
||||
- `convertHandler` should correctly return an error on a double-fraction (i.e. `3/2/3`).
|
||||
- `convertHandler` should correctly default to a numerical input of `1` when no numerical input is provided.
|
||||
- `convertHandler` should correctly read each valid input unit.
|
||||
- `convertHandler` should correctly return an error for an invalid input unit.
|
||||
- `convertHandler` should return the correct return unit for each valid input unit.
|
||||
- `convertHandler` should correctly return the spelled-out string unit for each valid input unit.
|
||||
- `convertHandler` should correctly convert `gal` to `L`.
|
||||
- `convertHandler` should correctly convert `L` to `gal`.
|
||||
- `convertHandler` should correctly convert `mi` to `km`.
|
||||
- `convertHandler` should correctly convert `km` to `mi`.
|
||||
- `convertHandler` should correctly convert `lbs` to `kg`.
|
||||
- `convertHandler` should correctly convert `kg` to `lbs`.
|
||||
- `convertHandler` 应该正确地读取整个数字输入。
|
||||
- `convertHandler` 应该正确地读取十进制数字输入。
|
||||
- `convertHandler` 应该正确地读取一个分数输入。
|
||||
- `convertHandler` 应该正确地读取一个带小数点的分数输入。
|
||||
- `convertHandler` 当输入双分数时应该返回错误 ( `3/2/3`)。
|
||||
- `convertHandler` 在没有提供数字输入时应该默认为 `1`。
|
||||
- `convertHandler` 应该正确地读取每个有效的单位输入。
|
||||
- `convertHandler` 在输入无效单位时应返回错误。
|
||||
- `convertHandler` 在输入有效单位时应返回正确的单位。
|
||||
- `convertHandler` 应该正确返回每个有效输入单位的拼写字符串。
|
||||
- `convertHandler` 应该正确地将 `gal` 转换为 `L`。
|
||||
- `convertHandler` 应该正确地将 `L` 转换为 `gal`。
|
||||
- `convertHandler` 应该正确地将 `mi` 转换为 `km`。
|
||||
- `convertHandler` 应该正确地将 `km` 转换为 `mi`。
|
||||
- `convertHandler` 应该正确地将 `lbs` 转换为 `kg`。
|
||||
- `convertHandler` 应该正确地将 `kg` 转换为 `lbs`。
|
||||
|
||||
Write the following tests in `tests/2_functional-tests.js`:
|
||||
在 `tests/2_functional-tests.js` 中写下以下测试:
|
||||
|
||||
- Convert a valid input such as `10L`: `GET` request to `/api/convert`.
|
||||
- Convert an invalid input such as `32g`: `GET` request to `/api/convert`.
|
||||
- Convert an invalid number such as `3/7.2/4kg`: `GET` request to `/api/convert`.
|
||||
- Convert an invalid number AND unit such as `3/7.2/4kilomegagram`: `GET` request to `/api/convert`.
|
||||
- Convert with no number such as `kg`: `GET` request to `/api/convert`.
|
||||
- 将有效的输入转换为 `10L`: `GET` 请求到 `/api/convert`。
|
||||
- 转换无效的输如 `32g`: `GET` 请求到 `/api/convert`.
|
||||
- 转换无效的数字,例如 `3/7.2/4kg`: `GET` 请求到 `/api/convert`。
|
||||
- 转换无效的数字和单位如 `3/7.2/4kilomegagram`: `GET` 请求到 `/api/convert`.
|
||||
- 转换时没有数字,例如 `kg`: `GET` 请求到 `/api/convert`。
|
||||
|
||||
# --hints--
|
||||
|
||||
You can provide your own project, not the example URL.
|
||||
提交自己的项目,而不是示例的 URL。
|
||||
|
||||
```js
|
||||
getUserInput => {
|
||||
@@ -65,11 +65,13 @@ getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
You can `GET` `/api/convert` with a single parameter containing an accepted number and unit and have it converted. (Hint: Split the input by looking for the index of the first character which will mark the start of the unit)
|
||||
通过 `GET` 请求 `/api/convert`,传入数字和单位的单个参数,可以将其转换。 (提示:通过寻找第一个字符的索引来分割输入,这将标记单位的开始)
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
You can convert `'gal'` to `'L'` and vice versa. (1 gal to 3.78541 L)
|
||||
可以将 `'gal'` 转换为 `'L'`,反之亦然。 (1 gal to 3.78541 L)
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -92,7 +94,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
You can convert `'lbs'` to `'kg'` and vice versa. (1 lbs to 0.453592 kg)
|
||||
可以将 `'lbs'` 转换为 `'kg'`,反之亦然。 (1 lbs to 0.453592 kg)
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -115,7 +117,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
You can convert `'mi'` to `'km'` and vice versa. (1 mi to 1.60934 km)
|
||||
你可以将 `'mi'` 转换为 `'km'` 反之亦然。 (1 mi to 1.60934 km)
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -138,7 +140,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
All incoming units should be accepted in both upper and lower case, but should be returned in both the `initUnit` and `returnUnit` in lower case, except for liter, which should be represented as an uppercase `'L'`.
|
||||
所有输入单位以大写和小写形式都应该被接受,但在 `initUnit` 和 `returnUnit` 中应以小写形式返回,升除外,应将其表示为大写的 `'L'`。
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -161,7 +163,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
If the unit of measurement is invalid, returned will be `'invalid unit'`.
|
||||
如果测量单位无效,返回将为 `'invalid unit'`。
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -174,7 +176,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
If the number is invalid, returned will be `'invalid number'`.
|
||||
如果数字无效,返回将为 `'invalid number'`。
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -189,7 +191,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
If both the unit and number are invalid, returned will be `'invalid number and unit'`.
|
||||
如果单位和数字都无效,返回将为 `'invalid number and unit'`。
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -207,7 +209,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
You can use fractions, decimals or both in the parameter (ie. 5, 1/2, 2.5/6), but if nothing is provided it will default to 1.
|
||||
可以在参数中使用分数、小数或小数分数 (例如 5, 1/2, 2.5/6),如果没有提供任何内容,则默认值为 1。
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -238,7 +240,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
Your return will consist of the `initNum`, `initUnit`, `returnNum`, `returnUnit`, and `string` spelling out units in the format `'{initNum} {initUnitString} converts to {returnNum} {returnUnitString}'` with the result rounded to 5 decimals.
|
||||
返回将包含 `initNum`、`initUnit`、`returnNum`、`returnUnit` 和 `string` 拼写单位格式 `'{initNum} {initUnitString} converts to {returnNum} {returnUnitString}'` 结果四舍五入为 5 小数。
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -255,7 +257,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
All 16 unit tests are complete and passing.
|
||||
所有 16 个单元的测试都已完成并通过。
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
@@ -280,7 +282,7 @@ async getUserInput => {
|
||||
};
|
||||
```
|
||||
|
||||
All 5 functional tests are complete and passing.
|
||||
所有 5 项功能测试都已完成并通过。
|
||||
|
||||
```js
|
||||
async getUserInput => {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824a367417b2b2512c43
|
||||
title: Personal Library
|
||||
title: 个人图书馆
|
||||
challengeType: 4
|
||||
forumTopicId: 301571
|
||||
dashedName: personal-library
|
||||
@@ -8,25 +8,25 @@ dashedName: personal-library
|
||||
|
||||
# --description--
|
||||
|
||||
Build a full stack JavaScript app that is functionally similar to this: <https://personal-library.freecodecamp.rocks/>. Working on this project will involve you writing your code using one of the following methods:
|
||||
构建一个 JavaScript 的全栈应用,在功能上与这个应用相似:<https://personal-library.freecodecamp.rocks/>。 可以采用下面的任意一种方式完成这个挑战:
|
||||
|
||||
- Clone [this GitHub repo](https://github.com/freeCodeCamp/boilerplate-project-library) and complete your project locally.
|
||||
- Use [our repl.it starter project](https://repl.it/github/freeCodeCamp/boilerplate-project-library)) to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
- 克隆 [这个 GitHub 仓库](https://github.com/freeCodeCamp/boilerplate-project-library) 并在本地完成项目。
|
||||
- 使用 [repl.it 上的初始化项目](https://repl.it/github/freeCodeCamp/boilerplate-project-library) 来完成项目。
|
||||
- 使用一个你喜欢的站点生成器来完成项目。 需要确定包含了我们 GitHub 仓库的所有文件。
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 框中提交你的项目 URL。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
|
||||
# --instructions--
|
||||
|
||||
1. Add your MongoDB connection string to `.env` without quotes as `DB`
|
||||
Example: `DB=mongodb://admin:pass@1234.mlab.com:1234/fccpersonallib`
|
||||
2. In your `.env` file set `NODE_ENV` to `test`, without quotes
|
||||
3. You need to create all routes within `routes/api.js`
|
||||
4. You will create all functional tests in `tests/2_functional-tests.js`
|
||||
1. 将的 MongoDB 连接字符串添加到 `.env` 中(没有引号),`DB`
|
||||
示例: `DB=mongodb://admin:pass@1234.mlab.com:1234/fccpersonallib`
|
||||
2. 在 `.env` 文件中设置 `NODE_ENV` 为 `test`中,没有引号
|
||||
3. 需要在 `routes/api.js` 中创建所有路由
|
||||
4. 在 `tests/2_functional-tests.js` 中创建所有的功能测试
|
||||
|
||||
# --hints--
|
||||
|
||||
You can provide your own project, not the example URL.
|
||||
提交自己的项目,而不是示例的 URL。
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -36,7 +36,7 @@ You can provide your own project, not the example URL.
|
||||
};
|
||||
```
|
||||
|
||||
You can send a <b>POST</b> request to `/api/books` with `title` as part of the form data to add a book. The returned response will be an object with the `title` and a unique `_id` as keys. If `title` is not included in the request, the returned response should be the string `missing required field title`.
|
||||
可以发送 <b>POST</b> 请求到 `/api/books`,带有 `title` 作为表单数据的一部分,来添加一本书。 返回的响应将是一个包含 `title` 和唯一的 `_id` 作为键的对象。 如果 `title` 未包含在请求中,返回的响应应该是字符串 `missing required field title`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -57,7 +57,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
You can send a <b>GET</b> request to `/api/books` and receive a JSON response representing all the books. The JSON response will be an array of objects with each object (book) containing `title`, `_id`, and `commentcount` properties.
|
||||
可以向 `/api/books` 发送 <b>GET</b> 请求,并返回代表所有书的 JSON 响应。 JSON 响应应该是一个包含有 `title`、`_id` 和 `commentcount` 属性的对象数组 。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -85,7 +85,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
You can send a <b>GET</b> request to `/api/books/{_id}` to retrieve a single object of a book containing the properties `title`, `_id`, and a `comments` array (empty array if no comments present). If no book is found, return the string `no book exists`.
|
||||
可以发送 <b>GET</b> 请求到 `/api/books/{_id}` 来检索一本书的单个对象,返回属性 `title`、`_id` 和 `comments` 数组 (如果没有评论,则展示空数组)。 如果找不到书, 返回字符串 `no book exists`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -109,7 +109,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
You can send a <b>POST</b> request containing `comment` as the form body data to `/api/books/{_id}` to add a comment to a book. The returned response will be the books object similar to <b>GET</b> `/api/books/{_id}` request in an earlier test. If `comment` is not included in the request, return the string `missing required field comment`. If no book is found, return the string `no book exists`.
|
||||
可以发送一个 <b>POST</b> 请求,其中包含 `comment` 作为表单正文数据,请求到 `/api/books/{_id}` 以便将评论添加到书中。 返回的响应将是书对象,在先前测试中 <b>GET</b> `/api/books/{_id}` 类似。 如果请求中没有包含 `comment` ,返回字符串 `missing required field comment`。 如果找不到书, 返回字符串 `no book exists`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -147,7 +147,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
You can send a <b>DELETE</b> request to `/api/books/{_id}` to delete a book from the collection. The returned response will be the string `delete successful` if successful. If no book is found, return the string `no book exists`.
|
||||
可以向 `/api/books/{_id}` 发送 <b>DELETE</b> 请求,从收藏中删除一本书。 如果成功,返回的响应将是字符串 `delete successful`。 如果找不到书, 返回字符串 `no book exists`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -171,7 +171,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
You can send a <b>DELETE</b> request to `/api/books` to delete all books in the database. The returned response will be the string `'complete delete successful` if successful.
|
||||
可以向 `/api/books` 发送 <b>DELETE</b> 请求来删除数据库中的所有书籍。 如果成功,返回的响应将是字符串 `'complete delete successful`。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -188,7 +188,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
All 10 functional tests required are complete and passing.
|
||||
所有 10 项功能测试都已完成并通过。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
@@ -1,66 +1,66 @@
|
||||
---
|
||||
id: 5e601bf95ac9d0ecd8b94afd
|
||||
title: Sudoku Solver
|
||||
title: 数独求解器
|
||||
challengeType: 4
|
||||
dashedName: sudoku-solver
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
Build a full stack JavaScript app that is functionally similar to this: <https://sudoku-solver.freecodecamp.rocks/>. Working on this project will involve you writing your code using one of the following methods:
|
||||
构建一个 JavaScript 的全栈应用,在功能上与这个应用相似:<https://sudoku-solver.freecodecamp.rocks/>。 可以采用下面的任意一种方式完成这个挑战:
|
||||
|
||||
- Clone [this GitHub repo](https://github.com/freecodecamp/boilerplate-project-sudoku-solver) and complete your project locally.
|
||||
- Use [our repl.it starter project](https://repl.it/github/freeCodeCamp/boilerplate-project-sudoku-solver) to complete your project.
|
||||
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
|
||||
- 克隆 [GitHub 仓库](https://github.com/freecodecamp/boilerplate-project-sudoku-solver) 并在本地完成你的项目。
|
||||
- 使用 [repl.it 初始化项目](https://repl.it/github/freeCodeCamp/boilerplate-project-sudoku-solver) 来完成项目。
|
||||
- 使用一个你喜欢的站点生成器来完成项目。 需要确定包含了我们 GitHub 仓库的所有文件。
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 框中提交你的项目 URL。 此外,还可以将项目的源码提交到 `GitHub Link` 中。
|
||||
|
||||
# --instructions--
|
||||
|
||||
- All puzzle logic can go into `/controllers/sudoku-solver.js`
|
||||
- The `validate` function should take a given puzzle string and check it to see if it has 81 valid characters for the input.
|
||||
- The `check` functions should be validating against the *current* state of the board.
|
||||
- The `solve` function should handle solving any given valid puzzle string, not just the test inputs and solutions. You are expected to write out the logic to solve this.
|
||||
- All routing logic can go into `/routes/api.js`
|
||||
- See the `puzzle-strings.js` file in `/controllers` for some sample puzzles your application should solve
|
||||
- To run the challenge tests on this page, set `NODE_ENV` to `test` without quotes in the `.env` file
|
||||
- To run the tests in the console, use the command `npm run test`. To open the Repl.it console, press Ctrl+Shift+P (Cmd if on a Mac) and type "open shell"
|
||||
- 所有解谜逻辑都可以进入 `/controllers/sudoku-solver.js`
|
||||
- `validate` 函数应该使用给定的解谜字符串,然后检查它是否是 81 个有效的输入字符。
|
||||
- `check` 函数应对棋盘的 *current* 进行验证。
|
||||
- `solve` 函数应该处理任何给定的解谜字符串,而不仅仅是测试输入和解决方法。 你需要写出解决这个问题的逻辑。
|
||||
- 所有路由逻辑都可以进入 `/routes/api.js`
|
||||
- 阅读 `/controllers` 中的 `puzzle-strings.js` 文件来了解一些应用程序应该解决的示例谜题
|
||||
- 在 `.env` 文件中将 `NODE_ENV` 设置为 `test` (没有引号),运行这个页面的挑战测试。
|
||||
- 使用 `npm run test` 命令在 console 中运行测试。 按 Ctrl+Shift+P (在 Mac 上是 Cmd+Shift+P) 并输入"open shell",打开 Repl.it 控制台。
|
||||
|
||||
Write the following tests in `tests/1_unit-tests.js`:
|
||||
在 `tests/1_unit-tests.js` 中写下以下测试:
|
||||
|
||||
- Logic handles a valid puzzle string of 81 characters
|
||||
- Logic handles a puzzle string with invalid characters (not 1-9 or `.`)
|
||||
- Logic handles a puzzle string that is not 81 characters in length
|
||||
- Logic handles a valid row placement
|
||||
- Logic handles an invalid row placement
|
||||
- Logic handles a valid column placement
|
||||
- Logic handles an invalid column placement
|
||||
- Logic handles a valid region (3x3 grid) placement
|
||||
- Logic handles an invalid region (3x3 grid) placement
|
||||
- Valid puzzle strings pass the solver
|
||||
- Invalid puzzle strings fail the solver
|
||||
- Solver returns the the expected solution for an incomplete puzzzle
|
||||
- 逻辑处理 81 个字符的解谜字符串
|
||||
- 逻辑处理无效的解谜字符串 (不是 1-9 或 `.`)
|
||||
- 逻辑处理一个长度不是 81 个字符的解谜字符串
|
||||
- 逻辑处理有效行的位置
|
||||
- 逻辑处理无效行的位置
|
||||
- 逻辑处理一个有效的列位置
|
||||
- 逻辑处理无效列位置
|
||||
- 逻辑处理一个有效的区域 (3x3 网格)
|
||||
- 逻辑处理一个无效的区域 (3x3 网格)
|
||||
- 有效解谜字符串通过 solver
|
||||
- 无效解谜字符串无法通过 solver
|
||||
- solver 返回一个不完整谜题的的预期解决方案
|
||||
|
||||
Write the following tests in `tests/2_functional-tests.js`
|
||||
在 `tests/2_functional-tests.js` 中编写下以下测试:
|
||||
|
||||
- Solve a puzzle with valid puzzle string: POST request to `/api/solve`
|
||||
- Solve a puzzle with missing puzzle string: POST request to `/api/solve`
|
||||
- Solve a puzzle with invalid characters: POST request to `/api/solve`
|
||||
- Solve a puzzle with incorrect length: POST request to `/api/solve`
|
||||
- Solve a puzzle that cannot be solved: POST request to `/api/solve`
|
||||
- Check a puzzle placement with all fields: POST request to `/api/check`
|
||||
- Check a puzzle placement with single placement conflict: POST request to `/api/check`
|
||||
- Check a puzzle placement with multiple placement conflicts: POST request to `/api/check`
|
||||
- Check a puzzle placement with all placement conflicts: POST request to `/api/check`
|
||||
- Check a puzzle placement with missing required fields: POST request to `/api/check`
|
||||
- Check a puzzle placement with invalid characters: POST request to `/api/check`
|
||||
- Check a puzzle placement with incorrect length: POST request to `/api/check`
|
||||
- Check a puzzle placement with invalid placement coordinate: POST request to `/api/check`
|
||||
- Check a puzzle placement with invalid placement value: POST request to `/api/check`
|
||||
- 用有效的解谜字符串解决一个谜题:POST 请求到 `/api/solve`
|
||||
- 用缺失的解谜字符串解决一个谜题:POST 请求到 `/api/solve`
|
||||
- 用无效字符解决一个谜题:POST 请求到 `/api/solve`
|
||||
- 用不正确的长度解决一个谜题:POST 请求到 `/api/solve`
|
||||
- 解决一个无法解决的谜题:POST 请求到 `/api/solve`
|
||||
- 检查所有字段的解谜位置:POST 请求到 `/api/check`
|
||||
- 用单个位置冲突检查解谜位置:POST 请求到 `/api/check`
|
||||
- 检查一个有多个位置冲突的解谜位置: POST 请求到 `/api/check`
|
||||
- 检查与所有位置冲突的解谜位置: POST 请求到 `/api/check`
|
||||
- 检查缺失所需字段的解谜位置:POST 请求到 `/api/check`
|
||||
- 检查一个有无效字符的解谜位置: POST 请求到 `/api/check`
|
||||
- 检查不正确长度的解谜位置:POST 请求到 `/api/check`
|
||||
- 检查一个无效的放置坐标的解谜位置:POST 请求到 `/api/check`
|
||||
- 检查具有无效的放置值的解谜位置:POST 请求到 `/api/check`
|
||||
|
||||
# --hints--
|
||||
|
||||
You should provide your own project, not the example URL.
|
||||
提交自己的项目,而不是示例的 URL。
|
||||
|
||||
```js
|
||||
(getUserInput) => {
|
||||
@@ -69,7 +69,7 @@ You should provide your own project, not the example URL.
|
||||
};
|
||||
```
|
||||
|
||||
You can `POST` `/api/solve` with form data containing `puzzle` which will be a string containing a combination of numbers (1-9) and periods `.` to represent empty spaces. The returned object will contain a `solution` property with the solved puzzle.
|
||||
可以发送 `POST` 请求到 `/api/solve`,使用包含 `puzzle` 的表单数据这将是一个包含数字 (1-9) 和点号的字符串组合,`.` 表示空格。 返回的对象将包含一个 `solution` 属性与解决的谜题。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -88,7 +88,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If the object submitted to `/api/solve` is missing `puzzle`, the returned value will be `{ error: 'Required field missing' }`
|
||||
如果提交给 `/api/solve` 的对象缺失 `puzzle`,返回的值将是 `{ error: 'Required field missing' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -106,7 +106,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If the puzzle submitted to `/api/solve` contains values which are not numbers or periods, the returned value will be `{ error: 'Invalid characters in puzzle' }`
|
||||
如果提交给 `/api/solve` 谜题包含非数字或点号的值。 返回的值将是 `{ error: 'Invalid characters in puzzle' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -124,7 +124,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If the puzzle submitted to `/api/solve` is greater or less than 81 characters, the returned value will be `{ error: 'Expected puzzle to be 81 characters long' }`
|
||||
如果提交给 `/api/solve` 的谜题大于或小于 81 个字符, 返回的值将是 `{ error: 'Expected puzzle to be 81 characters long' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -142,7 +142,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If the puzzle submitted to `/api/solve` is invalid or cannot be solved, the returned value will be `{ error: 'Puzzle cannot be solved' }`
|
||||
如果提交给 `/api/solve` 的谜题无效或无法解决, 返回的值将是 `{ error: 'Puzzle cannot be solved' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -160,7 +160,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
You can `POST` to `/api/check` an object containing `puzzle`, `coordinate`, and `value` where the `coordinate` is the letter A-I indicating the row, followed by a number 1-9 indicating the column, and `value` is a number from 1-9.
|
||||
可以发送 `POST` 请求到 `/api/check`,包含 `puzzle`、`coordinate` 和 `value` 的对象,其中 `coordinate` 是表示行的字母 A-I,后跟表示列的数字 1-9,而 `value` 是 1-9 的数字。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -179,7 +179,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
The return value from the `POST` to `/api/check` will be an object containing a `valid` property, which is `true` if the number may be placed at the provided coordinate and `false` if the number may not. If false, the returned object will also contain a `conflict` property which is an array containing the strings `"row"`, `"column"`, and/or `"region"` depending on which makes the placement invalid.
|
||||
发送 `POST` 请求到 `/api/check`,返回值是一个包含 `valid` 属性的对象,如果数字可能放置在提供的坐标中则是 `true`,否则是`false`。 如果错误,返回的对象还将包含一个 `conflict` 属性,它是一个字符串 `"row"`、`"column"`, 和/或 取决于哪个区域使位置无效的`"region"` 。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -202,7 +202,26 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If the puzzle submitted to `/api/check` contains values which are not numbers or periods, the returned value will be `{ error: 'Invalid characters in puzzle' }`
|
||||
如果提交给 `/api/check` 的 `value` 已放置在该 `coordinate` 上的 `puzzle`中,如果 `value` 不冲突,则返回的是 `valid` 属性为 `true` 的对象。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
const input =
|
||||
'..9..5.1.85.4....2432......1...69.83.9.....6.62.71...9......1945....4.37.4.3..6..';
|
||||
const coordinate = 'C3';
|
||||
const value = '2';
|
||||
const data = await fetch(getUserInput('url') + '/api/check', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ puzzle: input, coordinate, value })
|
||||
});
|
||||
const parsed = await data.json();
|
||||
assert.property(parsed, 'valid');
|
||||
assert.isTrue(parsed.valid);
|
||||
};
|
||||
```
|
||||
|
||||
如果提交给 `/api/check` 的谜题包含非数字或点号的值。 返回的值将是 `{ error: 'Invalid characters in puzzle' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -222,7 +241,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If the puzzle submitted to `/api/check` is greater or less than 81 characters, the returned value will be `{ error: 'Expected puzzle to be 81 characters long' }`
|
||||
如果提交给 `/api/check` 的谜题大于或小于 81 个字符, 返回的值将是 `{ error: 'Expected puzzle to be 81 characters long' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -242,7 +261,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If the object submitted to `/api/check` is missing `puzzle`, `coordinate` or `value`, the returned value will be `{ error: Required field(s) missing }`
|
||||
如果提交给 `/api/check` 的对象缺失 `puzzle`、`coordinate` 或 `value`,返回的值将是 `{ error: Required field(s) missing }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -260,7 +279,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If the coordinate submitted to `api/check` does not point to an existing grid cell, the returned value will be `{ error: 'Invalid coordinate'}`
|
||||
如果提交给 `api/check` 的坐标不指向现有的网格单元格, 返回的值将是 `{ error: 'Invalid coordinate'}`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -280,7 +299,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
If the `value` submitted to `/api/check` is not a number between 1 and 9, the returned values will be `{ error: 'Invalid value' }`
|
||||
如果提交给 `/api/check` 的 `value` 不是一个介于 1 到 9 之间的数字,则返回的值将是 `{ error: 'Invalid value' }`
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -300,7 +319,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
All 12 unit tests are complete and passing. See `/tests/1_unit-tests.js` for the expected behavior you should write tests for.
|
||||
所有 12 个单元的测试都已完成并通过。 请参阅 `/tests/1_unit-tests.js` 来了解你应该写的测试的预期行为。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
@@ -323,7 +342,7 @@ async (getUserInput) => {
|
||||
};
|
||||
```
|
||||
|
||||
All 14 functional tests are complete and passing. See `/tests/2_functional-tests.js` for the functionality you should write tests for.
|
||||
所有 14 项功能测试都已完成并通过。 请参阅 `/tests/2_functional-tests.js` 来了解你应该编写的测试的功能。
|
||||
|
||||
```js
|
||||
async (getUserInput) => {
|
||||
|
Reference in New Issue
Block a user