1.7 KiB
1.7 KiB
id, title, challengeType, forumTopicId
id | title | challengeType | forumTopicId |
---|---|---|---|
587d7b85367417b2b2512b3a | Catch Arguments Passed in the Wrong Order When Calling a Function | 1 | 301184 |
Description
Instructions
raiseToPower
raises a base to an exponent. Unfortunately, it's not called properly - fix the code so the value of power
is the expected 8.
Tests
tests:
- text: 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.
testString: assert(power == 8);
- text: Your code should use the correct order of the arguments for the <code>raiseToPower</code> function call.
testString: assert(code.match(/raiseToPower\(\s*?base\s*?,\s*?exp\s*?\);/g));
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
function raiseToPower(b, e) {
return Math.pow(b, e);
}
let base = 2;
let exp = 3;
let power = raiseToPower(base, exp);
console.log(power);