* fix: restructure certifications guide articles * fix: added 3 dashes line before prob expl * fix: added 3 dashes line before hints * fix: added 3 dashes line before solutions
849 B
849 B
title
title |
---|
Catch Arguments Passed in the Wrong Order When Calling a Function |
Catch Arguments Passed in the Wrong Order When Calling a Function
Problem Explanation
function raiseToPower(b, e) {
return Math.pow(b, e);
}
- The above function is used to raise the base number
b
to the power of the exponente
. - The function must be called specifically with variables in the correct order. Otherwise the function will mix up both variables and return an undesired answer.
- Make sure the variable
power
is implementing theraiseToPower
function correctly.
Solutions
Solution 1 (Click to Show/Hide)
function raiseToPower(b, e) {
return Math.pow(b, e);
}
let base = 2;
let exp = 3;
let power = raiseToPower(base, exp);
console.log(power);