1.8 KiB
1.8 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7b85367417b2b2512b3a | Catch Arguments Passed in the Wrong Order When Calling a Function | 1 | 调用函数时捕获以错误顺序传递的参数 |
Description
Instructions
raiseToPower
将基数提升为指数。不幸的是,它没有被正确调用 - 修复代码,因此power
值是预期的8。 Tests
tests:
- text: 你的代码应该固定可变<code>power</code>因此它等于2提升到3功率,而不是3增加到2功率。
testString: 'assert(power == 8, "Your code should fix the variable <code>power</code> so it equals 2 raised to the 3rd power, not 3 raised to the 2nd power.");'
- text: 您的代码应使用<code>raiseToPower</code>函数调用的正确参数顺序。
testString: 'assert(code.match(/raiseToPower\(\s*?base\s*?,\s*?exp\s*?\);/g), "Your code should use the correct order of the arguments for the <code>raiseToPower</code> function call.");'
Challenge Seed
function raiseToPower(b, e) {
return Math.pow(b, e);
}
let base = 2;
let exp = 3;
let power = raiseToPower(exp, base);
console.log(power);
Solution
// solution required