I dont understand why the function for the exponent isn’t working
https://codepen.io/coderkoji/pen/KKaeyJK
note: you’ll have to scroll down until the //6 appears
Why are you using a loop to do exponentiation? Are you not allowed to say something like
Math.pow(base, raise)
For this project im supposed to do it with loops.
Hello can you explain to me what this: You are returning answer
after the first iteration means please
Whenever a return
statement is executed, the function is exited immediately.
Thanks so much I finally figured it out
Here:
const exponent = (base,power) => {
let answer = base;
for (let i = 0; i < power-1; i++) {
answer *= base;
}
return answer;
}
1 Like
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.