Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

70 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 587d7b84367417b2b2512b35
title: 捕获拼错的变量名和函数名
challengeType: 1
forumTopicId: 301186
dashedName: catch-misspelled-variable-and-function-names
---
# --description--
`console.log()``typeof`方法是检查中间值和程序输出类型的两种主要方法。 现在是时候了解一下 bug 出现的常见的情形。一个语法级别的问题是打字太快带来的低级拼写错误。
变量或函数名的错写、漏写或大小写弄混都会让浏览器尝试查找并不存在的东西并报出“引用错误”。JavaScript 变量和函数名称区分大小写。
# --instructions--
修复代码中的两个拼写错误,以便`netWorkingCapital`计算有效。
# --hints--
检查计算 netWorkingCapital 值时使用的两个变量的拼写是否正确,控制台应该输出 "Net working capital is: 2"。
```js
assert(netWorkingCapital === 2);
```
代码中不应存在拼写错误的变量。
```js
assert(!code.match(/recievables/g));
```
应在代码中声明并正确使用`receivables`变量。
```js
assert(code.match(/receivables/g).length == 2);
```
代码中不应存在拼写错误的变量。
```js
assert(!code.match(/payable;/g));
```
应在代码中声明并正确使用`payables`变量。
```js
assert(code.match(/payables/g).length == 2);
```
# --seed--
## --seed-contents--
```js
let receivables = 10;
let payables = 8;
let netWorkingCapital = recievables - payable;
console.log(`Net working capital is: ${netWorkingCapital}`);
```
# --solutions--
```js
let receivables = 10;
let payables = 8;
let netWorkingCapital = receivables - payables;
console.log(`Net working capital is: ${netWorkingCapital}`);
```