Recursion and stack Flashcards
1
Q
A partial case of this is when a function calls itself. That’s called _______.
A
recursion
2
Q
function pow(x, n) {
let result = 1;
for (let i = 0; i < n; i++) {
result *= x;
}
return result;
}
write the above in a shorter way
function pow(x, n) {
/* coder here */
}
A
return (n == 1) ? x : (x * pow(x, n - 1));