Catch Arguments Passed in the Wrong Order When Calling a Function

Catch Arguments Passed in the Wrong Order When Calling a Function
0

#1

Tell us what’s happening:
I can’t tell the difference in the order of argument; 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 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 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


#2

The issue you are having is that the second challenge requirement says “Your code should use the correct order of the arguments for the raiseToPower function call.”

Instead of switching the order of the base and exponent parameters in your function, try switching the order of them inside the power variable.


#3

“Your code should use the correct order of the arguments for the raiseToPower function call” - it’s means that you just need put arguments for this function in logical sequence.


#4


it,s better to install vs code, because you will see the static function options.


#5

Did you end up figuring this out?


#6

Solution: function raiseToPower(b, e) {
return Math.pow(b, e);
}

let base = 2;
let exp = 3;
let power = raiseToPower(base, exp);
console.log(power);
The order of base and exp are changed,that means base x exp,so their values must be changed too.
(Have tried and passed)