--- id: 587d7b85367417b2b2512b3a title: Catch Arguments Passed in the Wrong Order When Calling a Function challengeType: 1 videoUrl: '' localeTitle: 调用函数时捕获以错误顺序传递的参数 --- ## Description
继续讨论调用函数,需要注意的下一个错误是函数的参数是以错误的顺序提供的。如果参数是不同的类型,例如期望数组和整数的函数,则可能会引发运行时错误。如果参数是相同的类型(例如,所有整数),那么代码的逻辑将没有意义。确保以正确的顺序提供所有必需的参数以避免这些问题。
## Instructions
函数raiseToPower将基数提升为指数。不幸的是,它没有被正确调用 - 修复代码,因此power值是预期的8。
## Tests
```yml tests: - text: 你的代码应该固定可变power因此它等于2提升到3功率,而不是3增加到2功率。 testString: 'assert(power == 8, "Your code should fix the variable power so it equals 2 raised to the 3rd power, not 3 raised to the 2nd power.");' - text: 您的代码应使用raiseToPower函数调用的正确参数顺序。 testString: 'assert(code.match(/raiseToPower\(\s*?base\s*?,\s*?exp\s*?\);/g), "Your code should use the correct order of the arguments for the raiseToPower function call.");' ```
## Challenge Seed
```js function raiseToPower(b, e) { return Math.pow(b, e); } let base = 2; let exp = 3; let power = raiseToPower(exp, base); console.log(power); ```
## Solution
```js // solution required ```