2019-05-06 11:31:26 +00:00
|
|
|
|
---
|
|
|
|
|
id: 587d7fb0367417b2b2512bed
|
2021-03-04 17:49:46 +00:00
|
|
|
|
title: 认识 Node 的控制台
|
2019-05-06 11:31:26 +00:00
|
|
|
|
challengeType: 2
|
2020-09-07 05:40:31 +00:00
|
|
|
|
forumTopicId: 301515
|
2021-01-13 02:31:00 +00:00
|
|
|
|
dashedName: meet-the-node-console
|
2019-05-06 11:31:26 +00:00
|
|
|
|
---
|
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
# --description--
|
|
|
|
|
|
2021-09-18 18:22:53 +00:00
|
|
|
|
你可以采用下面的任意一种编写代码的方式来完成这些挑战:
|
2020-12-16 07:37:30 +00:00
|
|
|
|
|
2021-03-04 17:49:46 +00:00
|
|
|
|
- 克隆 [这个 GitHub 仓库](https://github.com/freeCodeCamp/boilerplate-express/) 并在本地完成项目。
|
2021-05-12 15:55:58 +00:00
|
|
|
|
- 使用[我们的 Repl.it 上的初始化项目](https://replit.com/github/freeCodeCamp/boilerplate-express)来完成项目。
|
2021-09-18 18:22:53 +00:00
|
|
|
|
- 使用你选择的网站生成器来完成项目。 需要包含我们 GitHub 仓库的所有文件。
|
2021-02-06 04:42:36 +00:00
|
|
|
|
|
2021-09-18 18:22:53 +00:00
|
|
|
|
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 字段中提交它的 URL。
|
2019-05-06 11:31:26 +00:00
|
|
|
|
|
2021-03-04 17:49:46 +00:00
|
|
|
|
在开发过程中,能够随时看到代码的运行结果是非常重要的。
|
|
|
|
|
|
2021-05-12 15:55:58 +00:00
|
|
|
|
Node 只是一个 JavaScript 环境。 与客户端 JavaScript 一样,你可以使用控制台显示有用的调试信息。 在本地计算机上,你可以在终端中输出调试信息。 在 Replit 上,右侧边栏会默认打开一个终端。
|
2020-09-07 05:40:31 +00:00
|
|
|
|
|
2021-03-04 17:49:46 +00:00
|
|
|
|
我们建议在做这些挑战题时保持终端打开的状态。 通过这些终端的输出,你可能会发现这些错误的本质原因。
|
|
|
|
|
|
|
|
|
|
# --instructions--
|
2019-05-06 11:31:26 +00:00
|
|
|
|
|
2021-03-04 17:49:46 +00:00
|
|
|
|
修改 `myApp.js` 文件,在控制台打印出 “Hello World”。
|
2019-05-06 11:31:26 +00:00
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
# --hints--
|
2019-05-06 11:31:26 +00:00
|
|
|
|
|
2021-03-04 17:49:46 +00:00
|
|
|
|
控制台应该输出 `"Hello World"`
|
2019-05-06 11:31:26 +00:00
|
|
|
|
|
|
|
|
|
```js
|
2020-12-16 07:37:30 +00:00
|
|
|
|
(getUserInput) =>
|
|
|
|
|
$.get(getUserInput('url') + '/_api/hello-console').then(
|
|
|
|
|
(data) => {
|
|
|
|
|
assert.isTrue(data.passed, '"Hello World" is not in the server console');
|
|
|
|
|
},
|
|
|
|
|
(xhr) => {
|
|
|
|
|
throw new Error(xhr.responseText);
|
|
|
|
|
}
|
|
|
|
|
);
|
2019-05-06 11:31:26 +00:00
|
|
|
|
```
|
2020-08-13 15:24:35 +00:00
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
# --solutions--
|
|
|
|
|
|
2021-01-13 02:31:00 +00:00
|
|
|
|
```js
|
|
|
|
|
/**
|
|
|
|
|
Backend challenges don't need solutions,
|
|
|
|
|
because they would need to be tested against a full working project.
|
|
|
|
|
Please check our contributing guidelines to learn more.
|
|
|
|
|
*/
|
|
|
|
|
```
|