Tell us what’s happening:
Please help.
Your code so far
let base = 3;
let exp = 2;
function raiseToPower(exp, base) {
return Math.pow(exp, base);
}
let power = raiseToPower(exp, base);
console.log(power);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/debugging/catch-arguments-passed-in-the-wrong-order-when-calling-a-function
The arguments are being passed in the wrong order. Take a look at the documentation.
function raiseToPower(exp, base) {
return Math.pow(exp, base);
}
let base = 3;
let exp = 2;
let power = raiseToPower(exp, base);
console.log(power);
That??
You should only need to change this line:
let power = raiseToPower(exp, base);
And what to do.Because I don’t understand it
Change the order of the arguments.
Example:
function myFunction(argument1, argument2) {
return argument1 + ' ' + argument2;
}
var first = "Hello";
var second = "world";
myFunction(second, first); // "world Hello"
// should be in order
myFunction(first, second); // "Hello world"
let power = raiseToPower(2, 3);
That.
That’s the idea, but you can use the variable names that are provided.
function raiseToPower(exp, base) {
return Math.pow(exp, base);
}
let base = 2;
let exp = 3;
let power = raiseToPower(base, exp);
console.log(power);
YEAH this is right.
1 Like