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