Is 'Making our own stack' exercise broken?


#1
// Create an empty array called "stack"

// Here is our recursive function
function power(base, exponent) {
    var stack = [];
  // Base case 
  if ( exponent === 0 ) {
    return 1;
  }
  // Recursive case
  else {
	stack[exponent - 1] = base * power(base, exponent - 1);
    return stack[exponent - 1];
  }
}

This could, in theory, solves exactly what the prompt is asking for. I’m not sure why it doesn’t pass the checker and why I can’t move onto the next exercise. Also, this isn’t the right place to post this and it wasn’t very easy to find a section to post it.


#2

Please post a link to the exercise. Thanks.

Is the SCT expecting the array in global scope, before the function?

https://repl.it/@mtf/CC-recursive-power-function

I believe the author may have wanted a global object so we could log it out…


console.log(power(2,10));
console.log(stack);
1024
[ 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 ]