freeCodeCamp/curriculum/challenges/chinese/02-javascript-algorithms-an.../debugging/catch-misspelled-variable-a...

2.3 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
587d7b84367417b2b2512b35 Catch Misspelled Variable and Function Names 1 捕获拼错的变量和函数名称

Description

console.log()typeof方法是检查中间值和程序输出类型的两种主要方法。现在是时候进入错误所采用的常见形式了。快速打字机可以同意的一个语法级问题是简单的拼写错误。变量或函数名称中的转置,丢失或错误大写字符将使浏览器查找不存在的对象 - 并以引用错误的形式进行抱怨。 JavaScript变量和函数名称区分大小写。

Instructions

修复代码中的两个拼写错误,以便netWorkingCapital计算有效。

Tests

tests:
  - text: 检查netWorkingCapital计算中使用的两个变量的拼写控制台输出应显示“净营运资金为2”。
    testString: 'assert(netWorkingCapital === 2, "Check the spelling of the two variables used in the netWorkingCapital calculation, the console output should show that "Net working capital is: 2".");'
  - text: 代码中不应存在拼写错误的变量。
    testString: 'assert(!code.match(/recievables/g), "There should be no instances of mis-spelled variables in the code.");'
  - text: <code>receivables</code>在代码中声明并正确使用应<code>receivables</code>变量。
    testString: 'assert(code.match(/receivables/g).length == 2, "The <code>receivables</code> variable should be declared and used properly in the code.");'
  - text: 代码中不应存在拼写错误的变量。
    testString: 'assert(!code.match(/payable;/g), "There should be no instances of mis-spelled variables in the code.");'
  - text: 应在组织中声明并正确使用<code>payables</code>变量。
    testString: 'assert(code.match(/payables/g).length == 2, "The <code>payables</code> variable should be declared and used properly in the code.");'

Challenge Seed

let receivables = 10;
let payables = 8;
let netWorkingCapital = recievables - payable;
console.log(`Net working capital is: ${netWorkingCapital}`);

Solution

// solution required